diff --git a/NEWS b/NEWS index b9c83002..754b5919 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ ncmpcpp-0.8 (????-??-??) * Added support for fetching lyrics from tekstowo.pl. * The list of lyrics fetchers can now be set via configuration file. * Lyrics can now be fetched for songs with no tags. +* libcurl dependency is no longer optional. ncmpcpp-0.7.7 (2016-10-31) * Fixed compilation on 32bit platforms. diff --git a/configure.ac b/configure.ac index 4e63d515..798e260d 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,6 @@ AC_ARG_ENABLE(visualizer, AS_HELP_STRING([--enable-visualizer], [Enable music vi AC_ARG_ENABLE(clock, AS_HELP_STRING([--enable-clock], [Enable clock screen @<:@default=no@:>@]), [clock=$enableval], [clock=no]) AC_ARG_ENABLE(unicode, AS_HELP_STRING([--enable-unicode], [Enable utf8 support @<:@default=yes@:>@]), [unicode=$enableval], [unicode=yes]) -AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl], [Enable fetching lyrics from the Internet @<:@default=auto@:>@]), [curl=$withval], [curl=auto]) AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto]) AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto]) @@ -232,31 +231,42 @@ if test "$visualizer" = "yes" ; then AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen]) fi -dnl ===================== -dnl = checking for curl = -dnl ===================== -if test "$curl" != "no" ; then - AC_PATH_PROG(CURL_CONFIG, curl-config) - if test "$CURL_CONFIG" != "" ; then - CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`" - AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS `$CURL_CONFIG --libs`", - if test "$curl" = "yes" ; then - AC_MSG_ERROR([curl library is required]) - fi - ) - AC_CHECK_HEADERS([curl/curl.h], , - if test "$curl" = "yes" ; then - AC_MSG_ERROR([missing curl.h header]) - fi - ) - else - AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS -lcurl", - if test "$curl" = "yes" ; then - AC_MSG_ERROR([curl library is required]) - fi - ) - fi -fi +dnl ======================== +dnl = checking for libcurl = +dnl ======================== +PKG_CHECK_MODULES([libcurl], [libcurl], [ + AC_SUBST(libcurl_CFLAGS) + AC_SUBST(libcurl_LIBS) + CPPFLAGS="$CPPFLAGS $libcurl_CFLAGS" + AC_CHECK_HEADERS([curl/curl.h], + LIBS="$LIBS $libcurl_LIBS" + , + AC_MSG_ERROR([missing curl/curl.h header]) + ) +], + AC_MSG_ERROR([libcurl is required!]) +) + +dnl AC_PATH_PROG(CURL_CONFIG, curl-config) +dnl if test "$CURL_CONFIG" != "" ; then +dnl CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`" +dnl AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS `$CURL_CONFIG --libs`", +dnl if test "$curl" = "yes" ; then +dnl AC_MSG_ERROR([curl library is required]) +dnl fi +dnl ) +dnl AC_CHECK_HEADERS([curl/curl.h], , +dnl if test "$curl" = "yes" ; then +dnl AC_MSG_ERROR([missing curl.h header]) +dnl fi +dnl ) +dnl else +dnl AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS -lcurl", +dnl if test "$curl" = "yes" ; then +dnl AC_MSG_ERROR([curl library is required]) +dnl fi +dnl ) +dnl fi dnl ======================= dnl = checking for taglib = diff --git a/src/actions.cpp b/src/actions.cpp index 636f1da0..8f35b70a 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -135,11 +135,8 @@ void initializeScreens() mySongInfo = new SongInfo; myServerInfo = new ServerInfo; mySortPlaylistDialog = new SortPlaylistDialog; - -# ifdef HAVE_CURL_CURL_H myLastfm = new Lastfm; -# endif // HAVE_CURL_CURL_H - + # ifdef HAVE_TAGLIB_H myTinyTagEditor = new TinyTagEditor; myTagEditor = new TagEditor; @@ -172,11 +169,8 @@ void setResizeFlags() mySongInfo->hasToBeResized = 1; myServerInfo->hasToBeResized = 1; mySortPlaylistDialog->hasToBeResized = 1; - -# ifdef HAVE_CURL_CURL_H myLastfm->hasToBeResized = 1; -# endif // HAVE_CURL_CURL_H - + # ifdef HAVE_TAGLIB_H myTinyTagEditor->hasToBeResized = 1; myTagEditor->hasToBeResized = 1; @@ -1138,35 +1132,16 @@ void ToggleLyricsUpdateOnSongChange::run() ); } -#ifndef HAVE_CURL_CURL_H -bool ToggleLyricsFetcher::canBeRun() -{ - return false; -} -#endif // NOT HAVE_CURL_CURL_H - void ToggleLyricsFetcher::run() { -# ifdef HAVE_CURL_CURL_H myLyrics->toggleFetcher(); -# endif // HAVE_CURL_CURL_H } -#ifndef HAVE_CURL_CURL_H -bool ToggleFetchingLyricsInBackground::canBeRun() -{ - return false; -} -#endif // NOT HAVE_CURL_CURL_H - void ToggleFetchingLyricsInBackground::run() { -# ifdef HAVE_CURL_CURL_H Config.fetch_lyrics_in_background = !Config.fetch_lyrics_in_background; Statusbar::printf("Fetching lyrics for playing songs in background: %1%", - Config.fetch_lyrics_in_background ? "on" : "off" - ); -# endif // HAVE_CURL_CURL_H + Config.fetch_lyrics_in_background ? "on" : "off"); } void TogglePlayingSongCentering::run() @@ -2003,11 +1978,8 @@ void ApplyFilter::run() bool Find::canBeRun() { return myScreen == myHelp - || myScreen == myLyrics -# ifdef HAVE_CURL_CURL_H - || myScreen == myLastfm -# endif // HAVE_CURL_CURL_H - ; + || myScreen == myLyrics + || myScreen == myLastfm; } void Find::run() @@ -2299,18 +2271,12 @@ void ToggleMediaLibrarySortMode::run() bool RefetchLyrics::canBeRun() { -# ifdef HAVE_CURL_CURL_H return myScreen == myLyrics; -# else - return false; -# endif // HAVE_CURL_CURL_H } void RefetchLyrics::run() { -# ifdef HAVE_CURL_CURL_H myLyrics->refetchCurrent(); -# endif // HAVE_CURL_CURL_H } bool SetSelectedItemsPriority::canBeRun() @@ -2402,20 +2368,15 @@ void ShowSongInfo::run() bool ShowArtistInfo::canBeRun() { - #ifdef HAVE_CURL_CURL_H return myScreen == myLastfm - || (myScreen->isActiveWindow(myLibrary->Tags) - && !myLibrary->Tags.empty() - && Config.media_lib_primary_tag == MPD_TAG_ARTIST) - || currentSong(myScreen); -# else - return false; -# endif // NOT HAVE_CURL_CURL_H + || (myScreen->isActiveWindow(myLibrary->Tags) + && !myLibrary->Tags.empty() + && Config.media_lib_primary_tag == MPD_TAG_ARTIST) + || currentSong(myScreen); } void ShowArtistInfo::run() { -# ifdef HAVE_CURL_CURL_H if (myScreen == myLastfm) { myLastfm->switchTo(); @@ -2441,7 +2402,6 @@ void ShowArtistInfo::run() myLastfm->queueJob(new LastFm::ArtistInfo(artist, Config.lastfm_preferred_language)); myLastfm->switchTo(); } -# endif // HAVE_CURL_CURL_H } bool ShowLyrics::canBeRun() diff --git a/src/actions.h b/src/actions.h index b8bf1eb6..18141313 100644 --- a/src/actions.h +++ b/src/actions.h @@ -644,9 +644,6 @@ struct ToggleLyricsFetcher: BaseAction ToggleLyricsFetcher(): BaseAction(Type::ToggleLyricsFetcher, "toggle_lyrics_fetcher") { } private: -# ifndef HAVE_CURL_CURL_H - virtual bool canBeRun() override; -# endif // NOT HAVE_CURL_CURL_H virtual void run() override; }; @@ -656,9 +653,6 @@ struct ToggleFetchingLyricsInBackground: BaseAction : BaseAction(Type::ToggleFetchingLyricsInBackground, "toggle_fetching_lyrics_in_background") { } private: -# ifndef HAVE_CURL_CURL_H - virtual bool canBeRun() override; -# endif // NOT HAVE_CURL_CURL_H virtual void run() override; }; diff --git a/src/configuration.cpp b/src/configuration.cpp index 5068e915..b5ef96e1 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -106,9 +106,6 @@ bool configure(int argc, char **argv) << " - tag editor\n" << " - tiny tag editor\n" # endif - # ifdef HAVE_CURL_CURL_H - << " - artist info\n" - # endif # ifdef ENABLE_OUTPUTS << " - outputs\n" # endif @@ -125,9 +122,6 @@ bool configure(int argc, char **argv) << "disabled" # endif // HAVE_LANGINFO_H << "\nbuilt with support for:" - # ifdef HAVE_CURL_CURL_H - << " curl" - # endif # ifdef HAVE_FFTW3_H << " fftw" # endif diff --git a/src/curl_handle.cpp b/src/curl_handle.cpp index de1295db..06f7fb05 100644 --- a/src/curl_handle.cpp +++ b/src/curl_handle.cpp @@ -20,8 +20,6 @@ #include "curl_handle.h" -#ifdef HAVE_CURL_CURL_H - #include namespace @@ -62,5 +60,3 @@ std::string Curl::escape(const std::string &s) curl_free(cs); return result; } - -#endif // HAVE_CURL_CURL_H diff --git a/src/curl_handle.h b/src/curl_handle.h index 8ef89f70..ee83d73e 100644 --- a/src/curl_handle.h +++ b/src/curl_handle.h @@ -23,8 +23,6 @@ #include "config.h" -#ifdef HAVE_CURL_CURL_H - #include #include "curl/curl.h" @@ -35,7 +33,4 @@ namespace Curl std::string escape(const std::string &s); } -#endif // HAVE_CURL_CURL_H - #endif // NCMPCPP_CURL_HANDLE_H - diff --git a/src/help.cpp b/src/help.cpp index c34ad125..065a74bb 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -229,11 +229,9 @@ void write_bindings(NC::Scrollpad &w) key(w, Type::ToggleSeparatorsBetweenAlbums, "Toggle displaying separators between albums"); key(w, Type::JumpToPositionInSong, "Jump to given position in playing song (formats: mm:ss, x%)"); key(w, Type::ShowSongInfo, "Show song info"); -# ifdef HAVE_CURL_CURL_H key(w, Type::ShowArtistInfo, "Show artist info"); key(w, Type::ToggleLyricsFetcher, "Toggle lyrics fetcher"); key(w, Type::ToggleFetchingLyricsInBackground, "Toggle fetching lyrics for playing songs in background"); -# endif // HAVE_CURL_CURL_H key(w, Type::ShowLyrics, "Show/hide song lyrics"); w << '\n'; key(w, Type::Quit, "Quit"); diff --git a/src/lastfm.cpp b/src/lastfm.cpp index 587e4355..3f35617a 100644 --- a/src/lastfm.cpp +++ b/src/lastfm.cpp @@ -20,8 +20,6 @@ #include "lastfm.h" -#ifdef HAVE_CURL_CURL_H - #include "helpers.h" #include "charset.h" #include "global.h" @@ -89,5 +87,3 @@ void Lastfm::getResult() // reset m_worker so it's no longer valid m_worker = std::future(); } - -#endif // HVAE_CURL_CURL_H diff --git a/src/lastfm.h b/src/lastfm.h index b3b875f4..94cae36d 100644 --- a/src/lastfm.h +++ b/src/lastfm.h @@ -23,8 +23,6 @@ #include "config.h" -#ifdef HAVE_CURL_CURL_H - #include #include @@ -77,7 +75,4 @@ private: extern Lastfm *myLastfm; -#endif // HAVE_CURL_CURL_H - #endif // NCMPCPP_LASTFM_H - diff --git a/src/lastfm_service.cpp b/src/lastfm_service.cpp index 832ff391..af5dbaa9 100644 --- a/src/lastfm_service.cpp +++ b/src/lastfm_service.cpp @@ -20,8 +20,6 @@ #include "lastfm_service.h" -#ifdef HAVE_CURL_CURL_H - #include #include #include @@ -210,6 +208,3 @@ Service::Result ArtistInfo::processData(const std::string &data) } } - -#endif - diff --git a/src/lastfm_service.h b/src/lastfm_service.h index 976ddbb6..e3e7bac3 100644 --- a/src/lastfm_service.h +++ b/src/lastfm_service.h @@ -23,8 +23,6 @@ #include "config.h" -#ifdef HAVE_CURL_CURL_H - #include #include @@ -75,6 +73,4 @@ protected: } -#endif // HAVE_CURL_CURL_H - #endif // NCMPCPP_LASTFM_SERVICE_H diff --git a/src/lyrics.h b/src/lyrics.h index 48a82097..450a9166 100644 --- a/src/lyrics.h +++ b/src/lyrics.h @@ -105,4 +105,3 @@ private: extern Lyrics *myLyrics; #endif // NCMPCPP_LYRICS_H - diff --git a/src/lyrics_fetcher.cpp b/src/lyrics_fetcher.cpp index 377832d3..c9a5516f 100644 --- a/src/lyrics_fetcher.cpp +++ b/src/lyrics_fetcher.cpp @@ -21,8 +21,6 @@ #include "config.h" #include "curl_handle.h" -#ifdef HAVE_CURL_CURL_H - #include #include #include @@ -264,6 +262,3 @@ bool InternetLyricsFetcher::isURLOk(const std::string &url) URL = url; return false; } - -#endif // HAVE_CURL_CURL_H - diff --git a/src/lyrics_fetcher.h b/src/lyrics_fetcher.h index 442d5582..a6b7df79 100644 --- a/src/lyrics_fetcher.h +++ b/src/lyrics_fetcher.h @@ -23,8 +23,6 @@ #include "config.h" -#ifdef HAVE_CURL_CURL_H - #include #include @@ -156,6 +154,4 @@ private: std::string URL; }; -#endif // HAVE_CURL_CURL_H - #endif // NCMPCPP_LYRICS_FETCHER_H diff --git a/src/screen_type.cpp b/src/screen_type.cpp index 98b057c7..dfee9725 100644 --- a/src/screen_type.cpp +++ b/src/screen_type.cpp @@ -51,10 +51,8 @@ std::string screenTypeToString(ScreenType st) #endif // ENABLE_CLOCK case ScreenType::Help: return "help"; -#ifdef HAVE_CURL_CURL_H case ScreenType::Lastfm: return "last_fm"; -#endif // HAVE_CURL_CURL_H case ScreenType::Lyrics: return "lyrics"; case ScreenType::MediaLibrary: @@ -135,10 +133,8 @@ ScreenType stringToScreenType(const std::string &s) { if (s == "lyrics") result = ScreenType::Lyrics; -# ifdef HAVE_CURL_CURL_H else if (s == "last_fm") result = ScreenType::Lastfm; -# endif // HAVE_CURL_CURL_H else if (s == "selected_items_adder") result = ScreenType::SelectedItemsAdder; else if (s == "server_info") @@ -167,10 +163,8 @@ BaseScreen *toScreen(ScreenType st) # endif // ENABLE_CLOCK case ScreenType::Help: return myHelp; -# ifdef HAVE_CURL_CURL_H case ScreenType::Lastfm: return myLastfm; -# endif // HAVE_CURL_CURL_H case ScreenType::Lyrics: return myLyrics; case ScreenType::MediaLibrary: diff --git a/src/screen_type.h b/src/screen_type.h index 76f551c3..29be2515 100644 --- a/src/screen_type.h +++ b/src/screen_type.h @@ -33,9 +33,7 @@ enum class ScreenType { Clock, # endif // ENABLE_CLOCK Help, -# ifdef HAVE_CURL_CURL_H Lastfm, -# endif // HAVE_CURL_CURL_H Lyrics, MediaLibrary, # ifdef ENABLE_OUTPUTS diff --git a/src/status.cpp b/src/status.cpp index 70284c0e..019b6853 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -572,10 +572,8 @@ void Status::Changes::songID(int song_id) if (!Config.execute_on_song_change.empty()) res = system(Config.execute_on_song_change.c_str()); -# ifdef HAVE_CURL_CURL_H if (Config.fetch_lyrics_in_background) myLyrics->fetchInBackground(s); -# endif // HAVE_CURL_CURL_H drawTitle(s);