1
// -------------------------------------------------------------------------------- //
2
// Copyright (C) 2008-2010 J.Rios
5
// This Program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2, or (at your option)
10
// This Program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; see the file LICENSE. If not, write to
17
// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
// http://www.gnu.org/copyleft/gpl.html
20
// -------------------------------------------------------------------------------- //
26
#include "DbLibrary.h"
27
#include "Preferences.h"
29
#include <wx/string.h>
30
#include <wx/window.h>
32
#define guMAGNATUNE_DATABASE_DUMP_URL wxT( "http://he3.magnatune.com/info/album_info_xml.gz" )
33
//#define guMAGNATUNE_FILE_STREAM_URL
34
#define guMAGNATUNE_STREAM_FORMAT_MP3 wxT( ".mp3" )
35
#define guMAGNATUNE_STREAM_FORMAT_OGG wxT( ".ogg" )
37
#define guMAGNATUNE_ACTION_UPDATE 0 // Download the database and then upgrade
38
#define guMAGNATUNE_ACTION_UPGRADE 1 // Just refresh the tracks not updating the database
40
#define guMAGNATUNE_PARTNER_ID wxT( "guayadeque" )
41
#define guMAGNATUNE_DOWNLOAD_URL wxT( "http://%s:%s@download.magnatune.com/buy/membership_free_dl_xml.php?sku=%s&id=guayadeque" )
43
enum guMagnatune_Membership {
44
guMAGNATUNE_MEMBERSHIP_FREE,
45
guMAGNATUNE_MEMBERSHIP_STREAM,
46
guMAGNATUNE_MEMBERSHIP_DOWNLOAD
49
// -------------------------------------------------------------------------------- //
50
class guMagnatuneLibrary : public guDbLibrary
53
guMagnatuneLibrary( const wxString &libpath );
54
~guMagnatuneLibrary();
56
virtual void UpdateArtistsLabels( const guArrayListItems &labelsets );
57
virtual void UpdateAlbumsLabels( const guArrayListItems &labelsets );
58
virtual void UpdateSongsLabels( const guArrayListItems &labelsets );
60
void CreateNewSong( guTrack * track, const wxString &albumsku, const wxString &coverlink );
61
int GetTrackId( const wxString &url, guTrack * track = NULL );
63
wxString GetAlbumSku( const int trackid );
66
// -------------------------------------------------------------------------------- //
67
class guMagnatuneUpdateThread : public wxThread
70
guMagnatuneLibrary * m_Db;
71
guMainFrame * m_MainFrame;
74
wxSortedArrayString m_GenreList;
75
wxArrayString m_AllowedGenres;
76
guTrack m_CurrentTrack;
80
bool UpdateDatabase( void );
81
void ReadMagnatuneXmlTrack( wxXmlNode * xmlnode );
82
void ReadMagnatuneXmlAlbum( wxXmlNode * xmlnode );
83
void AddGenres( const wxString &genre );
89
guMagnatuneUpdateThread( guMagnatuneLibrary * db, const int action, int gaugeid );
90
~guMagnatuneUpdateThread();
96
class guMagnatuneDownloadThread;
98
// -------------------------------------------------------------------------------- //
99
class guMagnatunePanel : public guLibPanel
105
guMagnatuneUpdateThread * m_UpdateThread;
106
wxMutex m_UpdateThreadMutex;
108
virtual void NormalizeTracks( guTrackArray * tracks, const bool isdrag = false );
109
virtual void CreateContextMenu( wxMenu * menu, const int windowid = 0 );
110
void OnEditSetup( wxCommandEvent &event );
112
void OnUpdate( wxCommandEvent &event );
113
void OnUpgrade( wxCommandEvent &event );
114
void StartUpdateTracks( const int action );
116
void OnConfigUpdated( wxCommandEvent &event );
117
void OnCoverDownloaded( wxCommandEvent &event );
119
void OnAlbumDownloadCoverClicked( wxCommandEvent &event );
120
void OnAlbumSelectCoverClicked( wxCommandEvent &event );
122
void OnDownloadAlbum( wxCommandEvent &event );
123
void OnDownloadTrackAlbum( wxCommandEvent &event );
125
void DownloadAlbums( const wxArrayInt &albumids );
128
guMagnatunePanel( wxWindow * parent, guMagnatuneLibrary * db, guPlayerPanel * playerpanel, const wxString &prefix = wxT( "Jam" ) );
131
guMagnatuneLibrary * GetMagnatuneDb( void ) { return ( guMagnatuneLibrary * ) m_Db; }
132
wxImage * GetAlbumCover( const int albumid, const wxString &artist, const wxString &album, wxString &coverpath );
133
void AddDownload( const int albumid, const wxString &artist, const wxString &album );
135
void EndUpdateThread( void );
140
// -------------------------------------------------------------------------------- //
141
class guMagnatuneDownloadThread : public wxThread
144
guMagnatuneLibrary * m_Db;
145
guMagnatunePanel * m_MagnatunePanel;
146
wxString m_ArtistName;
147
wxString m_AlbumName;
151
guMagnatuneDownloadThread( guMagnatunePanel * jamendopanel, const int albumid,
152
const wxString &artist, const wxString &album );
153
~guMagnatuneDownloadThread();
160
// -------------------------------------------------------------------------------- //