get rid of using directives

these in ncmpcpp.cpp stay since a lot of memebers are used.
This commit is contained in:
Andrzej Rybczak
2010-01-22 19:17:35 +01:00
parent e9cd9c89ec
commit a27332a825
18 changed files with 257 additions and 233 deletions

View File

@@ -36,8 +36,14 @@
# include "tag_editor.h"
#endif // HAVE_TAGLIB_H
using namespace Global;
using namespace MPD;
using Global::MainHeight;
using Global::MainStartY;
using Global::myScreen;
using Global::RedrawHeader;
using MPD::itDirectory;
using MPD::itSong;
using MPD::itPlaylist;
Browser *myBrowser = new Browser;
@@ -51,7 +57,7 @@ const char *Browser::SupportedExtensions[] =
void Browser::Init()
{
w = new Menu<Item>(0, MainStartY, COLS, MainHeight, Config.columns_in_browser ? Display::Columns() : "", Config.main_color, brNone);
w = new Menu<MPD::Item>(0, MainStartY, COLS, MainHeight, Config.columns_in_browser ? Display::Columns() : "", Config.main_color, brNone);
w->HighlightColor(Config.main_highlight_color);
w->CyclicScrolling(Config.use_cyclic_scrolling);
w->SetSelectPrefix(&Config.selected_item_prefix);
@@ -89,7 +95,7 @@ void Browser::SwitchTo()
w->Empty() ? myBrowser->GetDirectory(itsBrowsedDir) : myBrowser->UpdateItemList();
if (myScreen != this && myScreen->isTabbable())
myPrevScreen = myScreen;
Global::myPrevScreen = myScreen;
myScreen = this;
RedrawHeader = 1;
}
@@ -97,7 +103,7 @@ void Browser::SwitchTo()
std::basic_string<my_char_t> Browser::Title()
{
std::basic_string<my_char_t> result = U("Browse: ");
result += Scroller(TO_WSTRING(itsBrowsedDir), itsScrollBeginning, w->GetWidth()-result.length()-(Config.new_design ? 2 : VolumeState.length()));
result += Scroller(TO_WSTRING(itsBrowsedDir), itsScrollBeginning, w->GetWidth()-result.length()-(Config.new_design ? 2 : Global::VolumeState.length()));
return result;
}
@@ -106,7 +112,7 @@ void Browser::EnterPressed()
if (w->Empty())
return;
const Item &item = w->Current();
const MPD::Item &item = w->Current();
switch (item.type)
{
case itDirectory:
@@ -122,7 +128,7 @@ void Browser::EnterPressed()
}
case itPlaylist:
{
SongList list;
MPD::SongList list;
Mpd.GetPlaylistContent(locale_to_utf_cpy(item.name), list);
if (myPlaylist->Add(list, 1))
ShowMessage("Loading and playing playlist %s...", item.name.c_str());
@@ -147,7 +153,7 @@ void Browser::SpacePressed()
if (itsBrowsedDir != "/" && w->Choice() == 0 /* parent dir */)
return;
const Item &item = w->Current();
const MPD::Item &item = w->Current();
switch (item.type)
{
case itDirectory:
@@ -155,11 +161,11 @@ void Browser::SpacePressed()
if (itsBrowsedDir != "/" && !w->Choice())
break; // do not let add parent dir.
SongList list;
MPD::SongList list;
# ifndef WIN32
if (isLocal())
{
ItemList items;
MPD::ItemList items;
ShowMessage("Scanning \"%s\"...", item.name.c_str());
myBrowser->GetLocalDirectory(items, item.name, 1);
list.reserve(items.size());
@@ -183,7 +189,7 @@ void Browser::SpacePressed()
}
case itPlaylist:
{
SongList list;
MPD::SongList list;
Mpd.GetPlaylistContent(locale_to_utf_cpy(item.name), list);
if (myPlaylist->Add(list, 0))
ShowMessage("Loading playlist %s...", item.name.c_str());
@@ -253,7 +259,7 @@ void Browser::GetSelectedSongs(MPD::SongList &v)
selected.push_back(w->Choice());
for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
{
const Item &item = w->at(*it);
const MPD::Item &item = w->at(*it);
switch (item.type)
{
case itDirectory:
@@ -273,7 +279,7 @@ void Browser::GetSelectedSongs(MPD::SongList &v)
}
case itSong:
{
v.push_back(new Song(*item.song));
v.push_back(new MPD::Song(*item.song));
break;
}
case itPlaylist:
@@ -350,16 +356,16 @@ void Browser::GetDirectory(std::string dir, std::string subdir)
if (dir != "/")
{
Item parent;
MPD::Item parent;
size_t slash = dir.rfind("/");
parent.song = reinterpret_cast<Song *>(1); // in that way we assume that's really parent dir
parent.song = reinterpret_cast<MPD::Song *>(1); // in that way we assume that's really parent dir
parent.name = slash != std::string::npos ? dir.substr(0, slash) : "/";
parent.type = itDirectory;
utf_to_locale(parent.name);
w->AddOption(parent);
}
ItemList list;
MPD::ItemList list;
# ifndef WIN32
isLocal() ? GetLocalDirectory(list) : Mpd.GetDirectory(dir, list);
# else
@@ -368,7 +374,7 @@ void Browser::GetDirectory(std::string dir, std::string subdir)
if (!isLocal()) // local directory is already sorted
sort(list.begin(), list.end(), CaseInsensitiveSorting());
for (ItemList::iterator it = list.begin(); it != list.end(); ++it)
for (MPD::ItemList::iterator it = list.begin(); it != list.end(); ++it)
{
switch (it->type)
{
@@ -407,7 +413,7 @@ void Browser::GetDirectory(std::string dir, std::string subdir)
}
#ifndef WIN32
void Browser::GetLocalDirectory(ItemList &v, const std::string &directory, bool recursively) const
void Browser::GetLocalDirectory(MPD::ItemList &v, const std::string &directory, bool recursively) const
{
DIR *dir = opendir((directory.empty() ? itsBrowsedDir : directory).c_str());
@@ -435,7 +441,7 @@ void Browser::GetLocalDirectory(ItemList &v, const std::string &directory, bool
{
if (!Config.local_browser_show_hidden_files && file->d_name[0] == '.')
continue;
Item new_item;
MPD::Item new_item;
full_path = directory.empty() ? itsBrowsedDir : directory;
if (itsBrowsedDir != "/")
full_path += "/";
@@ -459,7 +465,7 @@ void Browser::GetLocalDirectory(ItemList &v, const std::string &directory, bool
{
new_item.type = itSong;
mpd_pair file_pair = { "file", full_path.c_str() };
new_item.song = new Song(mpd_song_begin(&file_pair));
new_item.song = new MPD::Song(mpd_song_begin(&file_pair));
# ifdef HAVE_TAGLIB_H
if (!recursively)
TagEditor::ReadTags(*new_item.song);

View File

@@ -32,7 +32,9 @@
#include "settings.h"
#include "status.h"
using namespace Global;
using Global::MainHeight;
using Global::MainStartY;
using Global::myScreen;
Clock *myClock = new Clock;
@@ -88,10 +90,10 @@ void Clock::SwitchTo()
Resize();
if (myScreen != this && myScreen->isTabbable())
myPrevScreen = myScreen;
Global::myPrevScreen = myScreen;
myScreen = this;
myPlaylist->Items->Hide();
RedrawHeader = 1;
Global::RedrawHeader = 1;
Prepare();
// clearing screen apparently fixes the problem with last digits being misrendered
w->Clear();
@@ -109,7 +111,7 @@ void Clock::Update()
myPlaylist->SwitchTo();
static timeval past = { 0, 0 };
if (Timer.tv_sec <= past.tv_sec)
if (Global::Timer.tv_sec <= past.tv_sec)
return;
gettimeofday(&past, 0);

View File

@@ -29,8 +29,7 @@ namespace Global
{
extern BasicScreen *myScreen;
extern BasicScreen *myOldScreen; // for info, lyrics, popups
extern BasicScreen *myPrevScreen; // "real" screen switching
// (browser, search, etc.)
extern BasicScreen *myPrevScreen; // "real" screen switching (browser, search, etc.)
extern Window *wHeader;
extern Window *wFooter;

View File

@@ -25,7 +25,8 @@
#include "settings.h"
#include "tag_editor.h"
using namespace Global;
using Global::MainHeight;
using Global::MainStartY;
Help *myHelp = new Help;
@@ -46,6 +47,8 @@ void Help::Resize()
void Help::SwitchTo()
{
using Global::myScreen;
if (myScreen == this)
return;
@@ -56,9 +59,9 @@ void Help::SwitchTo()
Resize();
if (myScreen != this && myScreen->isTabbable())
myPrevScreen = myScreen;
Global::myPrevScreen = myScreen;
myScreen = this;
RedrawHeader = 1;
Global::RedrawHeader = 1;
}

View File

@@ -30,8 +30,6 @@
#include "status.h"
#include "tag_editor.h"
using namespace MPD;
bool ConnectToMPD()
{
if (!Mpd.Connect())
@@ -228,17 +226,17 @@ void ParseArgv(int argc, char **argv)
exit(0);
}
bool CaseInsensitiveSorting::operator()(const Item &a, const Item &b)
bool CaseInsensitiveSorting::operator()(const MPD::Item &a, const MPD::Item &b)
{
if (a.type == b.type)
{
switch (a.type)
{
case itDirectory:
case MPD::itDirectory:
return cmp(ExtractTopDirectory(a.name), ExtractTopDirectory(b.name)) < 0;
case itPlaylist:
case MPD::itPlaylist:
return cmp(a.name, b.name) < 0;
case itSong:
case MPD::itSong:
return Config.browser_sort_by_mtime
? a.song->GetMTime() > b.song->GetMTime()
: operator()(a.song, b.song);
@@ -258,7 +256,7 @@ std::string Timestamp(time_t t)
return result;
}
void UpdateSongList(Menu<Song> *menu)
void UpdateSongList(Menu<MPD::Song> *menu)
{
bool bold = 0;
for (size_t i = 0; i < menu->Size(); ++i)
@@ -278,21 +276,21 @@ void UpdateSongList(Menu<Song> *menu)
}
#ifdef HAVE_TAGLIB_H
std::string FindSharedDir(Menu<Song> *menu)
std::string FindSharedDir(Menu<MPD::Song> *menu)
{
SongList list;
MPD::SongList list;
for (size_t i = 0; i < menu->Size(); ++i)
list.push_back(&(*menu)[i]);
return FindSharedDir(list);
}
std::string FindSharedDir(const SongList &v)
std::string FindSharedDir(const MPD::SongList &v)
{
if (v.empty()) // this should never happen, but in case...
FatalError("empty SongList passed to FindSharedDir(const SongList &)!");
size_t i = -1;
std::string first = v.front()->GetDirectory();
for (SongList::const_iterator it = ++v.begin(); it != v.end(); ++it)
for (MPD::SongList::const_iterator it = ++v.begin(); it != v.end(); ++it)
{
size_t j = 0;
std::string dir = (*it)->GetDirectory();

View File

@@ -41,7 +41,10 @@
#include "status.h"
#include "tag_editor.h"
using namespace Global;
using Global::MainHeight;
using Global::MainStartY;
using Global::myScreen;
using Global::myOldScreen;
#ifdef HAVE_CURL_CURL_H
const std::string Info::Folder = home_path + HOME_FOLDER"artists";
@@ -123,7 +126,7 @@ void Info::GetSong()
myOldScreen = myScreen;
myScreen = this;
RedrawHeader = 1;
Global::RedrawHeader = 1;
itsTitle = "Song info";
w->Clear();
w->Reset();
@@ -170,7 +173,7 @@ void Info::GetArtist()
Resize();
myOldScreen = myScreen;
myScreen = this;
RedrawHeader = 1;
Global::RedrawHeader = 1;
itsTitle = "Artist info - " + itsArtist;
w->Clear();
w->Reset();
@@ -240,7 +243,7 @@ void *Info::PrepareArtist(void *screen_void_ptr)
std::string result;
CURLcode code;
pthread_mutex_lock(&CurlLock);
pthread_mutex_lock(&Global::CurlLock);
CURL *info = curl_easy_init();
curl_easy_setopt(info, CURLOPT_URL, url.c_str());
curl_easy_setopt(info, CURLOPT_WRITEFUNCTION, write_data);
@@ -249,7 +252,7 @@ void *Info::PrepareArtist(void *screen_void_ptr)
curl_easy_setopt(info, CURLOPT_NOSIGNAL, 1);
code = curl_easy_perform(info);
curl_easy_cleanup(info);
pthread_mutex_unlock(&CurlLock);
pthread_mutex_unlock(&Global::CurlLock);
curl_free(c_artist);

View File

@@ -49,7 +49,10 @@
# define LYRICS_FOLDER "/.lyrics"
#endif // WIN32
using namespace Global;
using Global::MainHeight;
using Global::MainStartY;
using Global::myScreen;
using Global::myOldScreen;
const std::string Lyrics::Folder = home_path + LYRICS_FOLDER;
@@ -128,7 +131,7 @@ void Lyrics::SwitchTo()
myOldScreen = myScreen;
myScreen = this;
}
RedrawHeader = 1;
Global::RedrawHeader = 1;
w->Clear();
w->Reset();
# ifdef HAVE_CURL_CURL_H
@@ -188,7 +191,7 @@ void Lyrics::SwitchTo()
std::basic_string<my_char_t> Lyrics::Title()
{
std::basic_string<my_char_t> result = U("Lyrics: ");
result += Scroller(TO_WSTRING(itsSong.toString("{%a - %t}")), itsScrollBegin, w->GetWidth()-result.length()-(Config.new_design ? 2 : VolumeState.length()));
result += Scroller(TO_WSTRING(itsSong.toString("{%a - %t}")), itsScrollBegin, w->GetWidth()-result.length()-(Config.new_design ? 2 : Global::VolumeState.length()));
return result;
}
@@ -216,7 +219,7 @@ void *Lyrics::Get(void *screen_void_ptr)
Replace(url, "%title%", c_title);
CURLcode code;
pthread_mutex_lock(&CurlLock);
pthread_mutex_lock(&Global::CurlLock);
CURL *lyrics = curl_easy_init();
curl_easy_setopt(lyrics, CURLOPT_URL, url.c_str());
curl_easy_setopt(lyrics, CURLOPT_WRITEFUNCTION, write_data);
@@ -225,7 +228,7 @@ void *Lyrics::Get(void *screen_void_ptr)
curl_easy_setopt(lyrics, CURLOPT_NOSIGNAL, 1);
code = curl_easy_perform(lyrics);
curl_easy_cleanup(lyrics);
pthread_mutex_unlock(&CurlLock);
pthread_mutex_unlock(&Global::CurlLock);
curl_free(c_artist);
curl_free(c_title);

View File

@@ -29,8 +29,9 @@
#include "playlist.h"
#include "status.h"
using namespace MPD;
using namespace Global;
using Global::MainHeight;
using Global::MainStartY;
using Global::myScreen;
MediaLibrary *myLibrary = new MediaLibrary;
@@ -66,7 +67,7 @@ void MediaLibrary::Init()
Albums->SetGetStringFunction(AlbumToString);
Albums->SetGetStringFunctionUserData(this);
Songs = new Menu<Song>(itsRightColStartX, MainStartY, itsRightColWidth, MainHeight, "Songs", Config.main_color, brNone);
Songs = new Menu<MPD::Song>(itsRightColStartX, MainStartY, itsRightColWidth, MainHeight, "Songs", Config.main_color, brNone);
Songs->HighlightColor(Config.main_highlight_color);
Songs->CyclicScrolling(Config.use_cyclic_scrolling);
Songs->SetSelectPrefix(&Config.selected_item_prefix);
@@ -151,9 +152,9 @@ void MediaLibrary::SwitchTo()
Resize();
if (myScreen != this && myScreen->isTabbable())
myPrevScreen = myScreen;
Global::myPrevScreen = myScreen;
myScreen = this;
RedrawHeader = 1;
Global::RedrawHeader = 1;
Refresh();
UpdateSongList(Songs);
}
@@ -167,11 +168,11 @@ void MediaLibrary::Update()
{
if (!hasTwoColumns && Artists->Empty())
{
TagList list;
MPD::TagList list;
Albums->Clear();
Mpd.GetList(list, Config.media_lib_primary_tag);
sort(list.begin(), list.end(), CaseInsensitiveSorting());
for (TagList::iterator it = list.begin(); it != list.end(); ++it)
for (MPD::TagList::iterator it = list.begin(); it != list.end(); ++it)
{
if (!it->empty())
{
@@ -187,23 +188,23 @@ void MediaLibrary::Update()
{
Songs->Clear();
Albums->Reset();
TagList list;
MPD::TagList list;
locale_to_utf(Artists->Current());
Mpd.StartFieldSearch(MPD_TAG_ALBUM);
Mpd.AddSearch(Config.media_lib_primary_tag, Artists->Current());
Mpd.CommitSearch(list);
for (TagList::iterator it = list.begin(); it != list.end(); ++it)
for (MPD::TagList::iterator it = list.begin(); it != list.end(); ++it)
{
if (Config.media_library_display_date)
{
TagList l;
MPD::TagList l;
Mpd.StartFieldSearch(MPD_TAG_DATE);
Mpd.AddSearch(Config.media_lib_primary_tag, Artists->Current());
Mpd.AddSearch(MPD_TAG_ALBUM, *it);
Mpd.CommitSearch(l);
utf_to_locale(*it);
for (TagList::iterator j = l.begin(); j != l.end(); ++j)
for (MPD::TagList::iterator j = l.begin(); j != l.end(); ++j)
{
utf_to_locale(*j);
Albums->AddOption(SearchConstraints(*it, *j));
@@ -223,32 +224,32 @@ void MediaLibrary::Update()
else if (hasTwoColumns && Albums->Empty())
{
Songs->Clear();
TagList artists;
MPD::TagList artists;
*Albums << XY(0, 0) << "Fetching albums...";
Albums->Window::Refresh();
Mpd.GetList(artists, Config.media_lib_primary_tag);
for (TagList::iterator i = artists.begin(); i != artists.end(); ++i)
for (MPD::TagList::iterator i = artists.begin(); i != artists.end(); ++i)
{
if (i->empty())
continue;
TagList albums;
MPD::TagList albums;
Mpd.StartFieldSearch(MPD_TAG_ALBUM);
Mpd.AddSearch(Config.media_lib_primary_tag, *i);
Mpd.CommitSearch(albums);
for (TagList::iterator j = albums.begin(); j != albums.end(); ++j)
for (MPD::TagList::iterator j = albums.begin(); j != albums.end(); ++j)
{
if (Config.media_library_display_date)
{
if (Config.media_lib_primary_tag != MPD_TAG_DATE)
{
TagList years;
MPD::TagList years;
Mpd.StartFieldSearch(MPD_TAG_DATE);
Mpd.AddSearch(Config.media_lib_primary_tag, *i);
Mpd.AddSearch(MPD_TAG_ALBUM, *j);
Mpd.CommitSearch(years);
utf_to_locale(*i);
utf_to_locale(*j);
for (TagList::iterator k = years.begin(); k != years.end(); ++k)
for (MPD::TagList::iterator k = years.begin(); k != years.end(); ++k)
{
utf_to_locale(*k);
Albums->AddOption(SearchConstraints(*i, *j, *k));
@@ -284,7 +285,7 @@ void MediaLibrary::Update()
if ((hasTwoColumns || !Artists->Empty()) && Songs->Empty())
{
Songs->Reset();
SongList list;
MPD::SongList list;
Mpd.StartSearch(1);
Mpd.AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(hasTwoColumns ? Albums->Current().Artist : Artists->Current()));
@@ -304,7 +305,7 @@ void MediaLibrary::Update()
sort(list.begin(), list.end(), SortSongsByTrack);
bool bold = 0;
for (SongList::const_iterator it = list.begin(); it != list.end(); ++it)
for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it)
{
for (size_t j = 0; j < myPlaylist->Items->Size(); ++j)
{
@@ -575,7 +576,7 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
if (myScreen != this)
SwitchTo();
Statusbar() << "Jumping to song...";
wFooter->Refresh();
Global::wFooter->Refresh();
if (!hasTwoColumns)
{
@@ -710,7 +711,7 @@ bool MediaLibrary::SearchConstraintsSorting::operator()(const SearchConstraints
return (result == 0 ? cmp(a.Album, b.Album) : result) < 0;
}
bool MediaLibrary::SortSongsByTrack(Song *a, Song *b)
bool MediaLibrary::SortSongsByTrack(MPD::Song *a, MPD::Song *b)
{
if (a->GetDisc() == b->GetDisc())
return StrToInt(a->GetTrack()) < StrToInt(b->GetTrack());

View File

@@ -26,31 +26,29 @@
#include "error.h"
#include "mpdpp.h"
using namespace MPD;
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";
Connection::Connection() : itsConnection(0),
isCommandsListEnabled(0),
itsMaxPlaylistLength(-1),
isIdle(0),
supportsIdle(0),
itsHost("localhost"),
itsPort(6600),
itsTimeout(15),
itsCurrentStatus(0),
itsOldStatus(0),
itsStats(0),
itsUpdater(0),
itsErrorHandler(0)
MPD::Connection::Connection() : itsConnection(0),
isCommandsListEnabled(0),
itsMaxPlaylistLength(-1),
isIdle(0),
supportsIdle(0),
itsHost("localhost"),
itsPort(6600),
itsTimeout(15),
itsCurrentStatus(0),
itsOldStatus(0),
itsStats(0),
itsUpdater(0),
itsErrorHandler(0)
{
}
Connection::~Connection()
MPD::Connection::~Connection()
{
if (itsConnection)
mpd_connection_free(itsConnection);
@@ -62,7 +60,7 @@ Connection::~Connection()
mpd_status_free(itsCurrentStatus);
}
bool Connection::Connect()
bool MPD::Connection::Connect()
{
if (itsConnection)
return true;
@@ -80,12 +78,12 @@ bool Connection::Connect()
return !CheckForErrors();
}
bool Connection::Connected() const
bool MPD::Connection::Connected() const
{
return itsConnection;
}
void Connection::Disconnect()
void MPD::Connection::Disconnect()
{
if (itsConnection)
mpd_connection_free(itsConnection);
@@ -104,7 +102,7 @@ void Connection::Disconnect()
itsMaxPlaylistLength = -1;
}
float Connection::Version() const
float MPD::Connection::Version() const
{
if (!itsConnection)
return 0;
@@ -112,7 +110,7 @@ float Connection::Version() const
return version[1] + version[2]*0.1;
}
void Connection::SetHostname(const std::string &host)
void MPD::Connection::SetHostname(const std::string &host)
{
size_t at = host.find("@");
if (at != std::string::npos)
@@ -124,7 +122,7 @@ void Connection::SetHostname(const std::string &host)
itsHost = host;
}
bool Connection::SendPassword()
bool MPD::Connection::SendPassword()
{
GoBusy();
assert(!isCommandsListEnabled);
@@ -132,25 +130,25 @@ bool Connection::SendPassword()
return !CheckForErrors();
}
void Connection::SetStatusUpdater(StatusUpdater updater, void *data)
void MPD::Connection::SetStatusUpdater(StatusUpdater updater, void *data)
{
itsUpdater = updater;
itsStatusUpdaterUserdata = data;
}
void Connection::SetErrorHandler(ErrorHandler handler, void *data)
void MPD::Connection::SetErrorHandler(ErrorHandler handler, void *data)
{
itsErrorHandler = handler;
itsErrorHandlerUserdata = data;
}
void Connection::GoIdle()
void MPD::Connection::GoIdle()
{
if (supportsIdle && !isIdle && mpd_send_idle(itsConnection))
isIdle = 1;
}
int Connection::GoBusy()
int MPD::Connection::GoBusy()
{
if (isIdle && mpd_send_noidle(itsConnection))
{
@@ -160,7 +158,7 @@ int Connection::GoBusy()
return 0;
}
void Connection::UpdateStatus()
void MPD::Connection::UpdateStatus()
{
if (!itsConnection)
return;
@@ -310,7 +308,7 @@ void Connection::UpdateStatus()
}
}
void Connection::UpdateStats()
void MPD::Connection::UpdateStats()
{
if (!itsConnection)
return;
@@ -322,7 +320,7 @@ void Connection::UpdateStats()
GoIdle();
}
bool Connection::UpdateDirectory(const std::string &path)
bool MPD::Connection::UpdateDirectory(const std::string &path)
{
if (!itsConnection)
return false;
@@ -342,7 +340,7 @@ bool Connection::UpdateDirectory(const std::string &path)
}
void Connection::Play()
void MPD::Connection::Play()
{
if (!itsConnection)
return;
@@ -358,7 +356,7 @@ void Connection::Play()
}
}
void Connection::Play(int pos)
void MPD::Connection::Play(int pos)
{
if (!itsConnection)
return;
@@ -374,7 +372,7 @@ void Connection::Play(int pos)
}
}
void Connection::PlayID(int id)
void MPD::Connection::PlayID(int id)
{
if (!itsConnection)
return;
@@ -390,7 +388,7 @@ void Connection::PlayID(int id)
}
}
void Connection::Pause(bool state)
void MPD::Connection::Pause(bool state)
{
if (!itsConnection)
return;
@@ -406,7 +404,7 @@ void Connection::Pause(bool state)
}
}
void Connection::Toggle()
void MPD::Connection::Toggle()
{
if (!itsConnection)
return;
@@ -428,7 +426,7 @@ void Connection::Toggle()
}
}
void Connection::Stop()
void MPD::Connection::Stop()
{
if (!itsConnection)
return;
@@ -444,7 +442,7 @@ void Connection::Stop()
}
}
void Connection::Next()
void MPD::Connection::Next()
{
if (!itsConnection)
return;
@@ -460,7 +458,7 @@ void Connection::Next()
}
}
void Connection::Prev()
void MPD::Connection::Prev()
{
if (!itsConnection)
return;
@@ -476,7 +474,7 @@ void Connection::Prev()
}
}
void Connection::Move(unsigned from, unsigned to)
void MPD::Connection::Move(unsigned from, unsigned to)
{
if (!itsConnection)
return;
@@ -492,7 +490,7 @@ void Connection::Move(unsigned from, unsigned to)
}
}
void Connection::Swap(unsigned from, unsigned to)
void MPD::Connection::Swap(unsigned from, unsigned to)
{
if (!itsConnection)
return;
@@ -508,7 +506,7 @@ void Connection::Swap(unsigned from, unsigned to)
}
}
void Connection::Seek(unsigned where)
void MPD::Connection::Seek(unsigned where)
{
if (!itsConnection)
return;
@@ -524,7 +522,7 @@ void Connection::Seek(unsigned where)
}
}
void Connection::Shuffle()
void MPD::Connection::Shuffle()
{
if (!itsConnection)
return;
@@ -540,7 +538,7 @@ void Connection::Shuffle()
}
}
void Connection::ClearPlaylist()
void MPD::Connection::ClearPlaylist()
{
if (!itsConnection)
return;
@@ -556,7 +554,7 @@ void Connection::ClearPlaylist()
}
}
void Connection::ClearPlaylist(const std::string &playlist)
void MPD::Connection::ClearPlaylist(const std::string &playlist)
{
if (!itsConnection)
return;
@@ -572,13 +570,13 @@ void Connection::ClearPlaylist(const std::string &playlist)
}
}
void Connection::AddToPlaylist(const std::string &path, const Song &s)
void MPD::Connection::AddToPlaylist(const std::string &path, const Song &s)
{
if (!s.Empty())
AddToPlaylist(path, s.GetFile());
}
void Connection::AddToPlaylist(const std::string &path, const std::string &file)
void MPD::Connection::AddToPlaylist(const std::string &path, const std::string &file)
{
if (!itsConnection)
return;
@@ -594,7 +592,7 @@ void Connection::AddToPlaylist(const std::string &path, const std::string &file)
}
}
void Connection::Move(const std::string &path, int from, int to)
void MPD::Connection::Move(const std::string &path, int from, int to)
{
if (!itsConnection)
return;
@@ -607,7 +605,7 @@ void Connection::Move(const std::string &path, int from, int to)
mpd_response_finish(itsConnection);
}
bool Connection::Rename(const std::string &from, const std::string &to)
bool MPD::Connection::Rename(const std::string &from, const std::string &to)
{
if (!itsConnection)
return false;
@@ -623,7 +621,7 @@ bool Connection::Rename(const std::string &from, const std::string &to)
}
}
void Connection::GetPlaylistChanges(unsigned version, SongList &v)
void MPD::Connection::GetPlaylistChanges(unsigned version, SongList &v)
{
if (!itsConnection)
return;
@@ -638,7 +636,7 @@ void Connection::GetPlaylistChanges(unsigned version, SongList &v)
GoIdle();
}
Song Connection::GetSong(const std::string &path)
MPD::Song MPD::Connection::GetSong(const std::string &path)
{
if (!itsConnection)
return Song();
@@ -651,12 +649,12 @@ Song Connection::GetSong(const std::string &path)
return Song(s);
}
int Connection::GetCurrentSongPos() const
int MPD::Connection::GetCurrentSongPos() const
{
return itsCurrentStatus && isPlaying() ? mpd_status_get_song_pos(itsCurrentStatus) : -1;
}
Song Connection::GetCurrentSong()
MPD::Song MPD::Connection::GetCurrentSong()
{
assert(!isCommandsListEnabled);
GoBusy();
@@ -665,7 +663,7 @@ Song Connection::GetCurrentSong()
return result;
}
void Connection::GetPlaylistContent(const std::string &path, SongList &v)
void MPD::Connection::GetPlaylistContent(const std::string &path, SongList &v)
{
if (!itsConnection)
return;
@@ -678,7 +676,7 @@ void Connection::GetPlaylistContent(const std::string &path, SongList &v)
GoIdle();
}
void Connection::SetRepeat(bool mode)
void MPD::Connection::SetRepeat(bool mode)
{
if (!itsConnection)
return;
@@ -694,7 +692,7 @@ void Connection::SetRepeat(bool mode)
}
}
void Connection::SetRandom(bool mode)
void MPD::Connection::SetRandom(bool mode)
{
if (!itsConnection)
return;
@@ -710,7 +708,7 @@ void Connection::SetRandom(bool mode)
}
}
void Connection::SetSingle(bool mode)
void MPD::Connection::SetSingle(bool mode)
{
if (!itsConnection)
return;
@@ -726,7 +724,7 @@ void Connection::SetSingle(bool mode)
}
}
void Connection::SetConsume(bool mode)
void MPD::Connection::SetConsume(bool mode)
{
if (!itsConnection)
return;
@@ -742,7 +740,7 @@ void Connection::SetConsume(bool mode)
}
}
void Connection::SetVolume(unsigned vol)
void MPD::Connection::SetVolume(unsigned vol)
{
if (!itsConnection || vol > 100)
return;
@@ -752,7 +750,7 @@ void Connection::SetVolume(unsigned vol)
UpdateStatus();
}
std::string Connection::GetReplayGainMode()
std::string MPD::Connection::GetReplayGainMode()
{
if (!itsConnection)
return "Unknown";
@@ -772,7 +770,7 @@ std::string Connection::GetReplayGainMode()
return result;
}
void Connection::SetReplayGainMode(ReplayGainMode mode)
void MPD::Connection::SetReplayGainMode(ReplayGainMode mode)
{
if (!itsConnection)
return;
@@ -801,7 +799,7 @@ void Connection::SetReplayGainMode(ReplayGainMode mode)
mpd_response_finish(itsConnection);
}
void Connection::SetCrossfade(unsigned crossfade)
void MPD::Connection::SetCrossfade(unsigned crossfade)
{
if (!itsConnection)
return;
@@ -817,7 +815,7 @@ void Connection::SetCrossfade(unsigned crossfade)
}
}
int Connection::AddSong(const std::string &path, int pos)
int MPD::Connection::AddSong(const std::string &path, int pos)
{
if (!itsConnection)
return -1;
@@ -845,12 +843,12 @@ int Connection::AddSong(const std::string &path, int pos)
return id;
}
int Connection::AddSong(const Song &s, int pos)
int MPD::Connection::AddSong(const Song &s, int pos)
{
return !s.Empty() ? (AddSong((!s.isFromDB() ? "file://" : "") + (s.Localized() ? locale_to_utf_cpy(s.GetFile()) : s.GetFile()), pos)) : -1;
}
void Connection::Add(const std::string &path)
void MPD::Connection::Add(const std::string &path)
{
if (!itsConnection)
return;
@@ -866,7 +864,7 @@ void Connection::Add(const std::string &path)
}
}
bool Connection::AddRandomSongs(size_t number)
bool MPD::Connection::AddRandomSongs(size_t number)
{
if (!itsConnection && !number)
return false;
@@ -902,7 +900,7 @@ bool Connection::AddRandomSongs(size_t number)
return true;
}
bool Connection::Delete(unsigned pos)
bool MPD::Connection::Delete(unsigned pos)
{
if (!itsConnection)
return false;
@@ -916,7 +914,7 @@ bool Connection::Delete(unsigned pos)
return result;
}
bool Connection::DeleteID(unsigned id)
bool MPD::Connection::DeleteID(unsigned id)
{
if (!itsConnection)
return false;
@@ -930,7 +928,7 @@ bool Connection::DeleteID(unsigned id)
return result;
}
bool Connection::Delete(const std::string &playlist, unsigned pos)
bool MPD::Connection::Delete(const std::string &playlist, unsigned pos)
{
if (!itsConnection)
return false;
@@ -946,7 +944,7 @@ bool Connection::Delete(const std::string &playlist, unsigned pos)
}
}
void Connection::StartCommandsList()
void MPD::Connection::StartCommandsList()
{
if (!itsConnection)
return;
@@ -956,7 +954,7 @@ void Connection::StartCommandsList()
isCommandsListEnabled = 1;
}
bool Connection::CommitCommandsList()
bool MPD::Connection::CommitCommandsList()
{
if (!itsConnection)
return false;
@@ -972,7 +970,7 @@ bool Connection::CommitCommandsList()
return result;
}
bool Connection::DeletePlaylist(const std::string &name)
bool MPD::Connection::DeletePlaylist(const std::string &name)
{
if (!itsConnection)
return false;
@@ -988,7 +986,7 @@ bool Connection::DeletePlaylist(const std::string &name)
}
}
bool Connection::SavePlaylist(const std::string &name)
bool MPD::Connection::SavePlaylist(const std::string &name)
{
if (!itsConnection)
return false;
@@ -1000,7 +998,7 @@ bool Connection::SavePlaylist(const std::string &name)
&& mpd_connection_get_server_error(itsConnection) == MPD_SERVER_ERROR_EXIST);
}
void Connection::GetPlaylists(TagList &v)
void MPD::Connection::GetPlaylists(TagList &v)
{
if (!itsConnection)
return;
@@ -1012,7 +1010,7 @@ void Connection::GetPlaylists(TagList &v)
FreeItemList(list);
}
void Connection::GetList(TagList &v, mpd_tag_type type)
void MPD::Connection::GetList(TagList &v, mpd_tag_type type)
{
if (!itsConnection)
return;
@@ -1029,13 +1027,13 @@ void Connection::GetList(TagList &v, mpd_tag_type type)
GoIdle();
}
void Connection::StartSearch(bool exact_match)
void MPD::Connection::StartSearch(bool exact_match)
{
if (itsConnection)
mpd_search_db_songs(itsConnection, exact_match);
}
void Connection::StartFieldSearch(mpd_tag_type item)
void MPD::Connection::StartFieldSearch(mpd_tag_type item)
{
if (itsConnection)
{
@@ -1044,7 +1042,7 @@ void Connection::StartFieldSearch(mpd_tag_type item)
}
}
void Connection::AddSearch(mpd_tag_type item, const std::string &str)
void MPD::Connection::AddSearch(mpd_tag_type item, const std::string &str)
{
// mpd version < 0.14.* doesn't support empty search constraints
if (Version() < 14 && str.empty())
@@ -1053,7 +1051,7 @@ void Connection::AddSearch(mpd_tag_type item, const std::string &str)
mpd_search_add_tag_constraint(itsConnection, MPD_OPERATOR_DEFAULT, item, str.c_str());
}
void Connection::CommitSearch(SongList &v)
void MPD::Connection::CommitSearch(SongList &v)
{
if (!itsConnection)
return;
@@ -1066,7 +1064,7 @@ void Connection::CommitSearch(SongList &v)
GoIdle();
}
void Connection::CommitSearch(TagList &v)
void MPD::Connection::CommitSearch(TagList &v)
{
if (!itsConnection)
return;
@@ -1082,7 +1080,7 @@ void Connection::CommitSearch(TagList &v)
GoIdle();
}
void Connection::GetDirectory(const std::string &path, ItemList &v)
void MPD::Connection::GetDirectory(const std::string &path, ItemList &v)
{
if (!itsConnection)
return;
@@ -1118,7 +1116,7 @@ void Connection::GetDirectory(const std::string &path, ItemList &v)
GoIdle();
}
void Connection::GetDirectoryRecursive(const std::string &path, SongList &v)
void MPD::Connection::GetDirectoryRecursive(const std::string &path, SongList &v)
{
if (!itsConnection)
return;
@@ -1131,7 +1129,7 @@ void Connection::GetDirectoryRecursive(const std::string &path, SongList &v)
GoIdle();
}
void Connection::GetSongs(const std::string &path, SongList &v)
void MPD::Connection::GetSongs(const std::string &path, SongList &v)
{
if (!itsConnection)
return;
@@ -1144,7 +1142,7 @@ void Connection::GetSongs(const std::string &path, SongList &v)
GoIdle();
}
void Connection::GetDirectories(const std::string &path, TagList &v)
void MPD::Connection::GetDirectories(const std::string &path, TagList &v)
{
if (!itsConnection)
return;
@@ -1160,7 +1158,7 @@ void Connection::GetDirectories(const std::string &path, TagList &v)
GoIdle();
}
void Connection::GetOutputs(OutputList &v)
void MPD::Connection::GetOutputs(OutputList &v)
{
if (!itsConnection)
return;
@@ -1176,7 +1174,7 @@ void Connection::GetOutputs(OutputList &v)
GoIdle();
}
bool Connection::EnableOutput(int id)
bool MPD::Connection::EnableOutput(int id)
{
if (!itsConnection)
return false;
@@ -1192,7 +1190,7 @@ bool Connection::EnableOutput(int id)
}
}
bool Connection::DisableOutput(int id)
bool MPD::Connection::DisableOutput(int id)
{
if (!itsConnection)
return false;
@@ -1208,7 +1206,7 @@ bool Connection::DisableOutput(int id)
}
}
void Connection::GetURLHandlers(TagList &v)
void MPD::Connection::GetURLHandlers(TagList &v)
{
if (!itsConnection)
return;
@@ -1224,7 +1222,7 @@ void Connection::GetURLHandlers(TagList &v)
GoIdle();
}
void Connection::GetTagTypes(TagList &v)
void MPD::Connection::GetTagTypes(TagList &v)
{
if (!itsConnection)
return;
@@ -1240,7 +1238,7 @@ void Connection::GetTagTypes(TagList &v)
GoIdle();
}
int Connection::CheckForErrors()
int MPD::Connection::CheckForErrors()
{
int error_code = 0;
if ((error_code = mpd_connection_get_error(itsConnection)) != MPD_ERROR_SUCCESS)

View File

@@ -25,7 +25,9 @@
#include "display.h"
#include "global.h"
using namespace Global;
using Global::MainHeight;
using Global::MainStartY;
using Global::myScreen;
Outputs *myOutputs = new Outputs;
@@ -52,11 +54,11 @@ void Outputs::SwitchTo()
Resize();
if (myScreen != this && myScreen->isTabbable())
myPrevScreen = myScreen;
Global::myPrevScreen = myScreen;
myScreen = this;
w->Window::Clear();
RedrawHeader = 1;
Global::RedrawHeader = 1;
}
void Outputs::Resize()

View File

@@ -28,7 +28,8 @@
#include "song.h"
#include "status.h"
using namespace Global;
using Global::MainHeight;
using Global::MainStartY;
Playlist *myPlaylist = new Playlist;
@@ -86,6 +87,8 @@ void Playlist::Init()
void Playlist::SwitchTo()
{
using Global::myScreen;
if (myScreen == this)
return;
@@ -98,13 +101,13 @@ void Playlist::SwitchTo()
Resize();
if (myScreen != this && myScreen->isTabbable())
myPrevScreen = myScreen;
Global::myPrevScreen = myScreen;
myScreen = this;
Items->Window::Clear();
EnableHighlighting();
if (w != Items) // even if sorting window is active, background has to be refreshed anyway
Items->Display();
RedrawHeader = 1;
Global::RedrawHeader = 1;
}
void Playlist::Resize()
@@ -132,7 +135,7 @@ std::basic_string<my_char_t> Playlist::Title()
std::basic_string<my_char_t> result = U("Playlist ");
if (ReloadTotalLength || ReloadRemaining)
itsBufferedStats = TotalLength();
result += Scroller(TO_WSTRING(itsBufferedStats), itsScrollBegin, Items->GetWidth()-result.length()-(Config.new_design ? 2 : VolumeState.length()));
result += Scroller(TO_WSTRING(itsBufferedStats), itsScrollBegin, Items->GetWidth()-result.length()-(Config.new_design ? 2 : Global::VolumeState.length()));
return result;
}
@@ -143,7 +146,7 @@ void Playlist::EnterPressed()
if (!Items->Empty())
{
Mpd.PlayID(Items->Current().GetID());
UpdateStatusImmediately = 1;
Global::UpdateStatusImmediately = 1;
}
}
else if (w == SortDialog)
@@ -425,7 +428,7 @@ std::string Playlist::SongInColumnsToString(const MPD::Song &s, void *)
bool Playlist::Add(const MPD::Song &s, bool in_playlist, bool play, int position)
{
BlockItemListUpdate = 1;
Global::BlockItemListUpdate = 1;
if (Config.ncmpc_like_songs_adding && in_playlist)
{
unsigned hash = s.GetHash();

View File

@@ -30,8 +30,8 @@
#include "status.h"
#include "tag_editor.h"
using namespace Global;
using namespace MPD;
using Global::MainHeight;
using Global::MainStartY;
PlaylistEditor *myPlaylistEditor = new PlaylistEditor;
@@ -50,7 +50,7 @@ void PlaylistEditor::Init()
Playlists->CyclicScrolling(Config.use_cyclic_scrolling);
Playlists->SetItemDisplayer(Display::Generic);
Content = new Menu<Song>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, "Playlist's content", Config.main_color, brNone);
Content = new Menu<MPD::Song>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, "Playlist's content", Config.main_color, brNone);
Content->HighlightColor(Config.main_highlight_color);
Content->CyclicScrolling(Config.use_cyclic_scrolling);
Content->SetSelectPrefix(&Config.selected_item_prefix);
@@ -93,6 +93,8 @@ void PlaylistEditor::Refresh()
void PlaylistEditor::SwitchTo()
{
using Global::myScreen;
if (myScreen == this)
return;
@@ -103,9 +105,9 @@ void PlaylistEditor::SwitchTo()
Resize();
if (myScreen != this && myScreen->isTabbable())
myPrevScreen = myScreen;
Global::myPrevScreen = myScreen;
myScreen = this;
RedrawHeader = 1;
Global::RedrawHeader = 1;
Refresh();
UpdateSongList(Content);
}
@@ -115,10 +117,10 @@ void PlaylistEditor::Update()
if (Playlists->Empty())
{
Content->Clear();
TagList list;
MPD::TagList list;
Mpd.GetPlaylists(list);
sort(list.begin(), list.end(), CaseInsensitiveSorting());
for (TagList::iterator it = list.begin(); it != list.end(); ++it)
for (MPD::TagList::iterator it = list.begin(); it != list.end(); ++it)
{
utf_to_locale(*it);
Playlists->AddOption(*it);
@@ -130,14 +132,14 @@ void PlaylistEditor::Update()
if (!Playlists->Empty() && Content->Empty())
{
Content->Reset();
SongList list;
MPD::SongList 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
Content->SetTitle("Playlist's content");
bool bold = 0;
for (SongList::const_iterator it = list.begin(); it != list.end(); ++it)
for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it)
{
for (size_t j = 0; j < myPlaylist->Items->Size(); ++j)
{
@@ -150,7 +152,7 @@ void PlaylistEditor::Update()
Content->AddOption(**it, bold);
bold = 0;
}
FreeSongList(list);
MPD::FreeSongList(list);
Content->Window::Clear();
Content->Display();
}
@@ -193,7 +195,7 @@ void PlaylistEditor::PrevColumn()
void PlaylistEditor::AddToPlaylist(bool add_n_play)
{
SongList list;
MPD::SongList list;
if (w == Playlists && !Playlists->Empty())
{

View File

@@ -28,8 +28,8 @@
#include "settings.h"
#include "status.h"
using namespace MPD;
using namespace Global;
using Global::MainHeight;
using Global::MainStartY;
SearchEngine *mySearcher = new SearchEngine;
@@ -59,7 +59,7 @@ int SearchEngine::CaseSensitive = REG_ICASE;
void SearchEngine::Init()
{
w = new Menu< std::pair<Buffer *, Song *> >(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
w = new Menu< std::pair<Buffer *, MPD::Song *> >(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
w->HighlightColor(Config.main_highlight_color);
w->CyclicScrolling(Config.use_cyclic_scrolling);
w->SetItemDisplayer(Display::SearchEngine);
@@ -78,6 +78,8 @@ void SearchEngine::Resize()
void SearchEngine::SwitchTo()
{
using Global::myScreen;
if (myScreen == this)
return;
@@ -91,9 +93,9 @@ void SearchEngine::SwitchTo()
Prepare();
if (myScreen != this && myScreen->isTabbable())
myPrevScreen = myScreen;
Global::myPrevScreen = myScreen;
myScreen = this;
RedrawHeader = 1;
Global::RedrawHeader = 1;
if (!w->Back().first)
{
@@ -118,7 +120,7 @@ void SearchEngine::EnterPressed()
if (option < 10)
{
Statusbar() << fmtBold << ConstraintsNames[option] << fmtBoldEnd << ' ';
itsConstraints[option] = wFooter->GetString(itsConstraints[option]);
itsConstraints[option] = Global::wFooter->GetString(itsConstraints[option]);
w->Current().first->Clear();
*w->Current().first << fmtBold << std::setw(10) << std::left << ConstraintsNames[option] << fmtBoldEnd << ' ';
ShowTag(*w->Current().first, itsConstraints[option]);
@@ -151,7 +153,7 @@ void SearchEngine::EnterPressed()
size_t found = w->Size()-SearchEngine::StaticOptions;
found += 3; // don't count options inserted below
w->InsertSeparator(ResetButton+1);
w->InsertOption(ResetButton+2, std::make_pair(static_cast<Buffer *>(0), static_cast<Song *>(0)), 1, 1);
w->InsertOption(ResetButton+2, std::make_pair(static_cast<Buffer *>(0), static_cast<MPD::Song *>(0)), 1, 1);
w->at(ResetButton+2).first = new Buffer();
*w->at(ResetButton+2).first << Config.color1 << "Search results: " << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") << clDefault;
w->InsertSeparator(ResetButton+3);
@@ -315,7 +317,7 @@ void SearchEngine::Search()
if (constraints_empty)
return;
SongList list;
MPD::SongList list;
if (Config.search_in_db)
Mpd.GetDirectoryRecursive("/", list);
else
@@ -328,7 +330,7 @@ void SearchEngine::Search()
bool any_found = 1;
bool found = 1;
for (SongList::const_iterator it = list.begin(); it != list.end(); ++it)
for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it)
{
if (MatchToPattern)
{
@@ -442,7 +444,7 @@ void SearchEngine::Search()
if (found && any_found)
{
Song *ss = Config.search_in_db ? *it : new Song(**it);
MPD::Song *ss = Config.search_in_db ? *it : new MPD::Song(**it);
w->AddOption(std::make_pair(static_cast<Buffer *>(0), ss));
list[it-list.begin()] = 0;
}
@@ -450,7 +452,7 @@ void SearchEngine::Search()
any_found = 1;
}
if (Config.search_in_db) // free song list only if it's database
FreeSongList(list);
MPD::FreeSongList(list);
}
bool SearchEngine::SEStringComparison(const std::string &a, const std::string &b, bool case_sensitive)

View File

@@ -25,7 +25,6 @@
using Global::MainHeight;
using Global::MainStartY;
using Global::myScreen;
using Global::myOldScreen;
ServerInfo *myServerInfo = new ServerInfo;
@@ -43,6 +42,8 @@ void ServerInfo::Init()
void ServerInfo::SwitchTo()
{
using Global::myScreen;
if (myScreen == this)
{
myOldScreen->SwitchTo();

View File

@@ -39,8 +39,11 @@
#include "status.h"
#include "tag_editor.h"
using namespace Global;
using namespace MPD;
using Global::myScreen;
using Global::wFooter;
using Global::Timer;
using Global::wHeader;
using Global::VolumeState;
bool Global::UpdateStatusImmediately = 0;
bool Global::RedrawStatusbar = 0;
@@ -129,12 +132,12 @@ void TraceMpdStatus()
static timeval past = { 0, 0 };
gettimeofday(&Global::Timer, 0);
if (Mpd.Connected() && (Mpd.SupportsIdle() || Timer.tv_sec > past.tv_sec || UpdateStatusImmediately))
if (Mpd.Connected() && (Mpd.SupportsIdle() || Timer.tv_sec > past.tv_sec || Global::UpdateStatusImmediately))
{
Mpd.UpdateStatus();
BlockItemListUpdate = 0;
Global::BlockItemListUpdate = 0;
Playlist::BlockUpdate = 0;
UpdateStatusImmediately = 0;
Global::UpdateStatusImmediately = 0;
if (!Mpd.SupportsIdle())
{
gettimeofday(&past, 0);
@@ -171,7 +174,7 @@ void TraceMpdStatus()
else
block_progressbar_update = !allow_statusbar_unlock;
if (Mpd.GetState() != psPlay && !block_statusbar_update && !block_progressbar_update)
if (Mpd.GetState() != MPD::psPlay && !block_statusbar_update && !block_progressbar_update)
{
if (Config.new_design)
DrawProgressbar(Mpd.GetElapsedTime(), Mpd.GetTotalTime());
@@ -183,7 +186,7 @@ void TraceMpdStatus()
}
}
void NcmpcppErrorCallback(Connection *, int errorid, const char *msg, void *)
void NcmpcppErrorCallback(MPD::Connection *, int errorid, const char *msg, void *)
{
if (errorid == MPD_SERVER_ERROR_PERMISSION)
{
@@ -198,7 +201,7 @@ void NcmpcppErrorCallback(Connection *, int errorid, const char *msg, void *)
ShowMessage("%s", msg);
}
void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
{
static size_t playing_song_scroll_begin = 0;
static size_t first_line_scroll_begin = 0;
@@ -222,7 +225,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
bool was_filtered = myPlaylist->Items->isFiltered();
myPlaylist->Items->ShowAll();
SongList list;
MPD::SongList list;
size_t playlist_length = Mpd.GetPlaylistLength();
if (playlist_length < myPlaylist->Items->Size())
@@ -230,7 +233,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
Mpd.GetPlaylistChanges(Mpd.GetOldPlaylistID(), list);
myPlaylist->Items->Reserve(playlist_length);
for (SongList::const_iterator it = list.begin(); it != list.end(); ++it)
for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it)
{
int pos = (*it)->GetPosition();
if (pos < int(myPlaylist->Items->Size()))
@@ -265,7 +268,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
ShowMessage("Cleared playlist!");
}
if (!BlockItemListUpdate)
if (!Global::BlockItemListUpdate)
{
if (myScreen == myBrowser)
{
@@ -316,27 +319,27 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
{
switch (Mpd.GetState())
{
case psUnknown:
case MPD::psUnknown:
{
player_state = "[unknown]";
break;
}
case psPlay:
case MPD::psPlay:
{
if (!np.Empty())
WindowTitle(utf_to_locale_cpy(np.toString(Config.song_window_title_format)));
player_state = Config.new_design ? "[playing]" : "Playing: ";
Playlist::ReloadRemaining = 1;
if (Mpd.GetOldState() == psStop) // show track info in status immediately
if (Mpd.GetOldState() == MPD::psStop) // show track info in status immediately
changed.ElapsedTime = 1;
break;
}
case psPause:
case MPD::psPause:
{
player_state = Config.new_design ? "[paused] " : "[Paused] ";
break;
}
case psStop:
case MPD::psStop:
{
WindowTitle("ncmpc++ ver. "VERSION);
if (!block_progressbar_update)
@@ -386,7 +389,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
if (Config.autocenter_mode && !myPlaylist->Items->isFiltered())
myPlaylist->Items->Highlight(myPlaylist->NowPlaying);
if (Config.now_playing_lyrics && !Mpd.GetSingle() && myScreen == myLyrics && myOldScreen == myPlaylist)
if (Config.now_playing_lyrics && !Mpd.GetSingle() && myScreen == myLyrics && Global::myOldScreen == myPlaylist)
Lyrics::Reload = 1;
}
Playlist::ReloadRemaining = 1;
@@ -394,7 +397,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
first_line_scroll_begin = 0;
second_line_scroll_begin = 0;
}
if (changed.ElapsedTime || changed.SongID || RedrawStatusbar)
if (changed.ElapsedTime || changed.SongID || Global::RedrawStatusbar)
{
if (np.Empty() && !(np = Mpd.GetCurrentSong()).Empty())
WindowTitle(utf_to_locale_cpy(np.toString(Config.song_window_title_format)));
@@ -406,10 +409,10 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
if (Config.display_remaining_time)
{
tracklength = "-";
tracklength += Song::ShowTime(Mpd.GetTotalTime()-Mpd.GetElapsedTime());
tracklength += MPD::Song::ShowTime(Mpd.GetTotalTime()-Mpd.GetElapsedTime());
}
else
tracklength = Song::ShowTime(Mpd.GetElapsedTime());
tracklength = MPD::Song::ShowTime(Mpd.GetElapsedTime());
if (Mpd.GetTotalTime())
{
tracklength += "/";
@@ -435,7 +438,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
size_t second_margin = (std::max(player_state.length(), size_t(8))+1)*2;
size_t second_start = second_len < COLS-second_margin ? (COLS-second_len)/2 : player_state.length()+1;
if (!SeekingInProgress)
if (!Global::SeekingInProgress)
*wHeader << XY(0, 0) << wclrtoeol << tracklength;
*wHeader << XY(first_start, 0);
first.Write(*wHeader, first_line_scroll_begin, COLS-tracklength.length()-VolumeState.length()-1, U(" ** "));
@@ -462,17 +465,17 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
if (Config.display_remaining_time)
{
tracklength += "-";
tracklength += Song::ShowTime(Mpd.GetTotalTime()-Mpd.GetElapsedTime());
tracklength += MPD::Song::ShowTime(Mpd.GetTotalTime()-Mpd.GetElapsedTime());
}
else
tracklength += Song::ShowTime(Mpd.GetElapsedTime());
tracklength += MPD::Song::ShowTime(Mpd.GetElapsedTime());
tracklength += "/";
tracklength += MPD::Song::ShowTime(Mpd.GetTotalTime());
tracklength += "]";
}
else
{
tracklength += Song::ShowTime(Mpd.GetElapsedTime());
tracklength += MPD::Song::ShowTime(Mpd.GetElapsedTime());
tracklength += "]";
}
basic_buffer<my_char_t> np_song;
@@ -483,7 +486,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
}
if (!block_progressbar_update)
DrawProgressbar(Mpd.GetElapsedTime(), Mpd.GetTotalTime());
RedrawStatusbar = 0;
Global::RedrawStatusbar = 0;
}
else
{
@@ -618,7 +621,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
}
*wFooter << fmtBoldEnd;
wFooter->GotoXY(sx, sy);
if (changed.PlayerState || (changed.ElapsedTime && (!Config.new_design || Mpd.GetState() == psPlay)))
if (changed.PlayerState || (changed.ElapsedTime && (!Config.new_design || Mpd.GetState() == MPD::psPlay)))
wFooter->Refresh();
if (changed.Playlist || changed.Database || changed.PlayerState || changed.SongID)
myScreen->RefreshWindow();
@@ -648,7 +651,7 @@ void DrawProgressbar(unsigned elapsed, unsigned time)
void ShowMessage(const char *format, ...)
{
if (MessagesAllowed && allow_statusbar_unlock)
if (Global::MessagesAllowed && allow_statusbar_unlock)
{
time(&time_of_statusbar_lock);
lock_statusbar_delay = Config.message_delay_time;

View File

@@ -40,10 +40,6 @@
using Global::MainHeight;
using Global::MainStartY;
using Global::myOldScreen;
using Global::myScreen;
using Global::myPrevScreen;
using Global::wFooter;
TagEditor *myTagEditor = new TagEditor;
@@ -189,6 +185,8 @@ std::basic_string<my_char_t> TagEditor::Title()
void TagEditor::SwitchTo()
{
using Global::myScreen;
if (myScreen == this)
return;
@@ -199,7 +197,7 @@ void TagEditor::SwitchTo()
Resize();
if (myScreen != this && myScreen->isTabbable())
myPrevScreen = myScreen;
Global::myPrevScreen = myScreen;
myScreen = this;
Global::RedrawHeader = 1;
Refresh();
@@ -323,6 +321,8 @@ void TagEditor::Update()
void TagEditor::EnterPressed()
{
using Global::wFooter;
if (w == Dirs)
{
MPD::TagList test;
@@ -996,7 +996,7 @@ bool TagEditor::WriteTags(MPD::Song &s)
locale_to_utf(new_name);
if (rename(path_to_file.c_str(), new_name.c_str()) == 0 && !file_is_from_db)
{
if (myOldScreen == myPlaylist)
if (Global::myOldScreen == myPlaylist)
{
// if we rename local file, it won't get updated
// so just remove it from playlist and add again

View File

@@ -39,8 +39,6 @@
using Global::MainHeight;
using Global::MainStartY;
using Global::myOldScreen;
using Global::myScreen;
using Global::wFooter;
TinyTagEditor *myTinyTagEditor = new TinyTagEditor;
@@ -70,8 +68,8 @@ void TinyTagEditor::SwitchTo()
{
if (hasToBeResized)
Resize();
myOldScreen = myScreen;
myScreen = this;
myOldScreen = Global::myScreen;
Global::myScreen = this;
Global::RedrawHeader = 1;
}
else
@@ -103,7 +101,7 @@ void TinyTagEditor::EnterPressed()
{
size_t pos = option-8;
Statusbar() << fmtBold << Info::Tags[pos].Name << ": " << fmtBoldEnd;
s.SetTags(Info::Tags[pos].Set, wFooter->GetString(s.GetTags(Info::Tags[pos].Get)));
s.SetTags(Info::Tags[pos].Set, Global::wFooter->GetString(s.GetTags(Info::Tags[pos].Get)));
w->at(option).Clear();
w->at(option) << fmtBold << Info::Tags[pos].Name << ':' << fmtBoldEnd << ' ';
ShowTag(w->at(option), s.GetTags(Info::Tags[pos].Get));
@@ -115,7 +113,7 @@ void TinyTagEditor::EnterPressed()
size_t dot = filename.rfind(".");
std::string extension = filename.substr(dot);
filename = filename.substr(0, dot);
std::string new_name = wFooter->GetString(filename);
std::string new_name = Global::wFooter->GetString(filename);
s.SetNewName(new_name + extension);
w->at(option).Clear();
w->at(option) << fmtBold << "Filename:" << fmtBoldEnd << ' ' << (s.GetNewName().empty() ? s.GetName() : s.GetNewName());

View File

@@ -31,8 +31,6 @@
#include <fcntl.h>
#include <sys/time.h>
using Global::myScreen;
using Global::myPrevScreen;
using Global::MainStartY;
using Global::MainHeight;
@@ -62,6 +60,8 @@ void Visualizer::Init()
void Visualizer::SwitchTo()
{
using Global::myScreen;
if (myScreen == this)
return;
@@ -72,7 +72,7 @@ void Visualizer::SwitchTo()
Resize();
if (myScreen != this && myScreen->isTabbable())
myPrevScreen = myScreen;
Global::myPrevScreen = myScreen;
myScreen = this;
w->Clear();