Skip to content

Commit

Permalink
Removed wxCurl code. Now using libcurl library directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
anonbeat committed Jun 11, 2016
1 parent ce1ab15 commit 077fcee
Show file tree
Hide file tree
Showing 27 changed files with 876 additions and 2,240 deletions.
4 changes: 2 additions & 2 deletions src/AccelListBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

#include "ItemListBox.h"

class guLibPanel;

namespace Guayadeque {

class guLibPanel;

// -------------------------------------------------------------------------------- //
class guAccelListBox : public guListBox
{
Expand Down
2 changes: 1 addition & 1 deletion src/AcousticId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#include "AcousticId.h"

#include "EventCommandIds.h"
#include "curl/http.h"
#include "MusicBrainz.h"
#include "Utils.h"
#include "Version.h"

#include <wx/sstream.h>
#include <wx/uri.h>

namespace Guayadeque {
Expand Down
30 changes: 13 additions & 17 deletions src/AudioScrobble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "PlayerPanel.h"
#include "Utils.h"

#include <wx/curl/http.h>
#include <wx/tokenzr.h>

namespace Guayadeque {
Expand Down Expand Up @@ -108,12 +107,11 @@ bool guAudioScrobbleSender::GetSessionId( void )

//guLogMessage( wxT( "AudioScrobble:GetSesionId : " ) + AS_Url );
char * Buffer = NULL;
wxCurlHTTP http;
http.AddHeader( wxT( "User-Agent: " ) guDEFAULT_BROWSER_USER_AGENT );
http.AddHeader( wxT( "Accept: text/html" ) );
http.AddHeader( wxT( "Accept-Charset: utf-8" ) );
http.SetOpt( CURLOPT_FOLLOWLOCATION, 1 );
http.Get( Buffer, AS_Url );
guHttp Http;
Http.AddHeader( wxT( "User-Agent" ), guDEFAULT_BROWSER_USER_AGENT );
Http.AddHeader( wxT( "Accept" ), wxT( "text/html" ) );
Http.AddHeader( wxT( "Accept-Charset" ), wxT( "utf-8" ) );
Http.Get( Buffer, AS_Url );
if( Buffer )
{
Content = wxString( Buffer, wxConvUTF8 );
Expand Down Expand Up @@ -168,7 +166,7 @@ bool guAudioScrobbleSender::SubmitPlayedSongs( const guAS_SubmitInfoArray &Playe
wxString Artist;
wxString Album;
wxString Track;
wxCurlHTTP http;
guHttp Http;

/*
s=<sessionID>
Expand Down Expand Up @@ -243,11 +241,10 @@ bool guAudioScrobbleSender::SubmitPlayedSongs( const guAS_SubmitInfoArray &Playe
PostData.RemoveLast( 1 ); // we remove the last & added

//guLogMessage( wxT( "AudioScrobble::Played : %s" ), PostData.c_str() );
http.AddHeader( wxT( "Content-Type: application/x-www-form-urlencoded" ) );
http.SetOpt( CURLOPT_FOLLOWLOCATION, 1 );
if( http.Post( wxCURL_STRING2BUF( PostData ), PostData.Length(), m_SubmitUrl ) )
Http.AddHeader( wxT( "Content-Type" ), wxT( "application/x-www-form-urlencoded" ) );
if( Http.Post( PostData.ToAscii(), PostData.Length(), m_SubmitUrl ) )
{
Content = http.GetResponseBody();
Content = Http.GetResData();
if( !Content.IsEmpty() )
{
//guLogMessage( wxT( "AudioScrobble::Response :\n%s" ), Content.c_str() );
Expand All @@ -272,7 +269,7 @@ bool guAudioScrobbleSender::SubmitPlayedSongs( const guAS_SubmitInfoArray &Playe
// -------------------------------------------------------------------------------- //
bool guAudioScrobbleSender::SubmitNowPlaying( const guAS_SubmitInfo * cursong )
{
wxCurlHTTP http;
guHttp Http;
wxString PostData;
wxString Content;
wxString Artist;
Expand Down Expand Up @@ -302,11 +299,10 @@ bool guAudioScrobbleSender::SubmitNowPlaying( const guAS_SubmitInfo * cursong )

//guLogMessage( wxT( "AudioScrobble::NowPlaying : " ) + m_NowPlayUrl + PostData );

http.AddHeader( wxT( "Content-Type: application/x-www-form-urlencoded" ) );
http.SetOpt( CURLOPT_FOLLOWLOCATION, 1 );
if( http.Post( wxCURL_STRING2BUF( PostData ), PostData.Length(), m_NowPlayUrl ) )
Http.AddHeader( wxT( "Content-Type" ), wxT( "application/x-www-form-urlencoded" ) );
if( Http.Post( PostData.ToAscii(), PostData.Length(), m_NowPlayUrl ) )
{
Content = http.GetResponseBody();
Content = Http.GetResData();
//guLogMessage( wxT( "%i : %s" ), http.GetResponseCode(), Content.c_str() );
if( !Content.IsEmpty() )
{
Expand Down
18 changes: 9 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ ENDIF( PROFILE )

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/wx
${CMAKE_CURRENT_SOURCE_DIR}/wx/curl
${CMAKE_CURRENT_SOURCE_DIR}/dbus
${CMAKE_CURRENT_SOURCE_DIR}/hmac
${CMAKE_CURRENT_SOURCE_DIR}/network
${GSTREAMER_INCLUDE_DIRS}
${GSTREAMER_CTRL_INCLUDE_DIRS}
${SQLITE3_INCLUDE_DIRS}
Expand All @@ -29,12 +28,6 @@ INCLUDE_DIRECTORIES(
${LIBAPPINDICATOR_INCLUDE_DIRS}
${LIBWXSQLITE3_INCLUDE_DIRS}
${LIBWXSQLITE330_INCLUDE_DIRS}

)

SET( CURL_SOURCES
curl/base.cpp
curl/http.cpp
)

SET( DBUS_SOURCES
Expand All @@ -59,6 +52,13 @@ SET( HMAC_SHA2_SOURCES
hmac/sha2.h
)

SET( NETWORK_SOURCES
network/Curl.cpp
network/Curl.h
network/Http.cpp
network/Http.h
)

ADD_EXECUTABLE( guayadeque
AlListBox.cpp
AlListBox.h
Expand Down Expand Up @@ -285,9 +285,9 @@ ADD_EXECUTABLE( guayadeque
AcousticId.h
MusicBrainz.cpp
MusicBrainz.h
${CURL_SOURCES}
${DBUS_SOURCES}
${HMAC_SHA2_SOURCES}
${NETWORK_SOURCES}
)

TARGET_LINK_LIBRARIES( guayadeque
Expand Down
1 change: 0 additions & 1 deletion src/CoverEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "Yahoo.h"

#include <wx/arrimpl.cpp>
#include <wx/curl/http.h>
#include <wx/statline.h>

#define MAX_COVERLINKS_ITEMS 30
Expand Down
1 change: 0 additions & 1 deletion src/Google.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "Utils.h"

#include <wx/arrimpl.cpp>
#include <wx/curl/http.h>
#include <wx/statline.h>
#include <wx/html/htmlpars.h>

Expand Down
15 changes: 7 additions & 8 deletions src/LastFM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "DbCache.h"
#include "Utils.h"

#include "curl/http.h"
#include "Http.h"

#include <wx/arrimpl.cpp>
#include <wx/sstream.h>
Expand Down Expand Up @@ -98,7 +98,7 @@ wxString guLastFMRequest::DoRequest( const bool AddSign, const bool IsGetAction
int Index;
int Count;
wxString RetVal = wxEmptyString;
wxCurlHTTP http;
guHttp Http;
char * Buffer = NULL;
wxString UrlStr = wxEmptyString; // = LASTFM_API_ROOT;

Expand Down Expand Up @@ -131,12 +131,11 @@ wxString guLastFMRequest::DoRequest( const bool AddSign, const bool IsGetAction
if( RetVal.IsEmpty() )
{
// Only with a UserAgent is accepted the Charset requested
http.AddHeader( wxT( "User-Agent: " ) guDEFAULT_BROWSER_USER_AGENT );
http.AddHeader( wxT( "Accept: text/html" ) );
http.AddHeader( wxT( "Accept-Charset: utf-8" ) );
Http.AddHeader( wxT( "User-Agent" ), guDEFAULT_BROWSER_USER_AGENT );
Http.AddHeader( wxT( "Accept" ), wxT( "text/html" ) );
Http.AddHeader( wxT( "Accept-Charset" ), wxT( "utf-8" ) );
//guLogMessage( wxT( "LastFM.DoRequest %s\n" ), UrlStr.c_str() );
http.SetOpt( CURLOPT_FOLLOWLOCATION, 1 );
http.Get( Buffer, UrlStr );
Http.Get( Buffer, UrlStr );

if( Buffer )
{
Expand All @@ -160,7 +159,7 @@ wxString guLastFMRequest::DoRequest( const bool AddSign, const bool IsGetAction
else
{
//guLogMessage( wxT( "LastFM.DoRequest POST %s\n" ), UrlStr.c_str() );
http.Post( UrlStr.Mid( 1 ).char_str(), UrlStr.Length() - 1, LASTFM_API_ROOT );
Http.Post( UrlStr.Mid( 1 ).char_str(), UrlStr.Length() - 1, LASTFM_API_ROOT );
}

// else
Expand Down
2 changes: 1 addition & 1 deletion src/LastFMPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "LastFMPanel.h"

#include "EventCommandIds.h"
#include "curl/http.h"
#include "Http.h"
#include "Images.h"
#include "MainApp.h"
#include "Settings.h"
Expand Down
2 changes: 1 addition & 1 deletion src/LyricsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "EventCommandIds.h"
#include "Config.h"
#include "curl/http.h"
#include "Preferences.h"
#include "Images.h"
#include "ListView.h"
Expand All @@ -38,6 +37,7 @@
#include <wx/txtstrm.h>
#include <wx/xml/xml.h>
#include <wx/regex.h>
#include <wx/sstream.h>
#include <wx/tokenzr.h>

namespace Guayadeque {
Expand Down
10 changes: 5 additions & 5 deletions src/MainApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "MainApp.h"

#include "Config.h"
#include "Curl.h"
#include "Images.h"
#include "MainFrame.h"
#include "mpris.h"
Expand All @@ -28,7 +29,6 @@
#include "Utils.h"

#include "wx/clipbrd.h"
#include <wx/curl/base.h>
#include <wx/image.h>
#include <wx/tooltip.h>
#include <wx/stdpaths.h>
Expand Down Expand Up @@ -345,8 +345,8 @@ bool guMainApp::OnInit()
// Use the primary clipboard which is shared with other applications
wxTheClipboard->UsePrimarySelection( false );

// Init the wxCurl Lib
wxCurlBase::Init();
// Init the Curl Library
guCurl::CurlInit();

int LangId = m_Config->ReadNum( wxT( "Language" ), wxLANGUAGE_DEFAULT, wxT( "general" ) );
if( m_Locale.Init( LangId ) )
Expand Down Expand Up @@ -414,8 +414,8 @@ bool guMainApp::OnInit()
// -------------------------------------------------------------------------------- //
int guMainApp::OnExit()
{
// Shutdown the wxCurl Lib
wxCurlBase::Shutdown();
// Free any resources used by Curl Library
guCurl::CurlDone();

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/MainFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "Config.h"
#include "CoverPanel.h"
#include "Collections.h"
#include "curl/http.h"
#include "Http.h"
#include "dbus/gudbus.h"
#include "dbus/mpris.h"
#include "dbus/mpris2.h"
Expand Down
2 changes: 1 addition & 1 deletion src/MusicBrainz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
// -------------------------------------------------------------------------------- //
#include "MusicBrainz.h"

//#include "Http.h"
#include "Utils.h"
#include "curl/http.h"

#include <wx/arrimpl.cpp>
#include <wx/sstream.h>
Expand Down
3 changes: 1 addition & 2 deletions src/Podcasts.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
#ifndef PODCASTS_H
#define PODCASTS_H

#include "curl/http.h"

#include <wx/dynarray.h>
#include <wx/xml/xml.h>
#include <wx/event.h>

namespace Guayadeque {

Expand Down
1 change: 0 additions & 1 deletion src/PodcastsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "NewChannel.h"
#include "Utils.h"

#include <wx/curl/http.h>
#include <wx/regex.h>
#include <wx/sstream.h>
#include <wx/uri.h>
Expand Down
1 change: 1 addition & 0 deletions src/Shoutcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

#include <wx/xml/xml.h>
#include <wx/fileconf.h>
#include <wx/sstream.h>

namespace Guayadeque {

Expand Down
3 changes: 1 addition & 2 deletions src/ShoutcastRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
#include "Config.h"
#include "DbCache.h"
#include "DbRadios.h"
#include "Http.h"
#include "Images.h"
#include "MainFrame.h"
#include "RadioPanel.h"
#include "RadioEditor.h"
#include "RadioGenreEditor.h"
#include "StatusBar.h"

#include "curl/http.h"

#include <wx/wfstream.h>
#include <wx/tokenzr.h>
#include <wx/xml/xml.h>
Expand Down
18 changes: 8 additions & 10 deletions src/TuneInRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
#include "Accelerators.h"
#include "DbCache.h"
#include "DbRadios.h"
#include "Http.h"
#include "Images.h"
#include "RadioPanel.h"
#include "RadioEditor.h"

#include "curl/http.h"

#include <wx/wfstream.h>
#include <wx/sstream.h>
#include <wx/tokenzr.h>
#include <wx/wfstream.h>
#include <wx/xml/xml.h>

namespace Guayadeque {
Expand Down Expand Up @@ -166,16 +166,14 @@ wxString GetTuneInUrl( const wxString &url )
if( Content.IsEmpty() )
{
char * Buffer = NULL;
wxCurlHTTP http;
guHttp Http;

// Only with a UserAgent is accepted the Charset requested
//http.AddHeader( wxT( "User-Agent: " "Dalvik/1.6.0.(Linux;.U;.Android.4.1.1;.Galaxy.Nexus.Build/JRO03L)" ) );
http.AddHeader( wxT( "User-Agent: " ) guDEFAULT_BROWSER_USER_AGENT );
http.AddHeader( wxT( "Accept: text/html" ) );
http.AddHeader( wxT( "Accept-Charset: utf-8" ) );
http.SetOpt( CURLOPT_FOLLOWLOCATION, 1 );
http.Get( Buffer, url );

Http.AddHeader( wxT( "User-Agent" ), guDEFAULT_BROWSER_USER_AGENT );
Http.AddHeader( wxT( "Accept" ), wxT( "text/html" ) );
Http.AddHeader( wxT( "Accept-Charset" ), wxT( "utf-8" ) );
Http.Get( Buffer, url );
if( Buffer )
{
Content = wxString( Buffer, wxConvUTF8 );
Expand Down

0 comments on commit 077fcee

Please sign in to comment.