Revert previous commit, was incorrect
[amarok.git] / src / servicebrowser / magnatunestore / MagnatuneStore.h
blob801b0897c3ea2424a76fad624d5e6aff58f7096d
1 /***************************************************************************
2 * Copyright (c) 2006, 2007 *
3 * Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
4 * *
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 of the License, or *
8 * (at your option) any later version. *
9 * *
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. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #ifndef AMAROKMAGNATUNESTORE_H
22 #define AMAROKMAGNATUNESTORE_H
25 #include "amarok.h"
26 //#include "magnatunepurchasedialog.h"
27 #include "magnatunepurchasehandler.h"
28 #include "magnatuneredownloadhandler.h"
29 #include "magnatunexmlparser.h"
30 #include "magnatunedatabasehandler.h"
32 #include "../servicebase.h"
33 #include "servicesqlcollection.h"
35 #include <kio/job.h>
36 #include <kio/jobclasses.h>
38 #include <QCheckBox>
39 #include <QComboBox>
40 #include <khbox.h>
41 #include <q3popupmenu.h>
42 #include <QPushButton>
43 #include <kvbox.h>
46 class MagnatuneServiceFactory: public ServiceFactory
48 Q_OBJECT
50 public:
51 MagnatuneServiceFactory() {}
52 virtual ~MagnatuneServiceFactory() {}
54 virtual void init();
55 virtual QString name();
56 virtual KPluginInfo info();
57 virtual KConfigGroup config();
61 /**
62 Amarok browser that displays all the music available at magnatune.com and makes it available for previewing and purchasing.
63 Implemented as a singleton
65 @author Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>
67 class MagnatuneStore: public ServiceBase
69 Q_OBJECT
71 public:
73 /**
74 * Constructor
76 MagnatuneStore( const char *name );
77 /**
78 * Destructor
80 ~MagnatuneStore() { }
82 /**
83 * Do not do expensive initializations before we are actually shown
85 void polish();
86 // bool updateContextView();
88 private slots:
90 /**
91 * Slot called when the purchase album button is clicked. Starts a purchase
93 void purchaseButtonClicked();
95 /**
96 * Slot for recieving notification that the update button has been clicked.
98 void updateButtonClicked();
102 * Slot for recieving notification when the Magnatune xml file has been downloaded.
103 * Triggers a parse of the file to get the info added to the databse
104 * @param downLoadJob The calling download Job
106 void listDownloadComplete( KJob* downLoadJob);
109 * Slot for catching cancelled list downloads
111 void listDownloadCancelled();
114 * Slot called when the parsing of the Magnatuin xml file is completed.
115 * Triggers an update of the list view and the genre combo box
117 void doneParsing();
120 * Starts the process of redownloading a previously bought album
122 void processRedownload();
125 * Slot for recieving notifications of completed purchase operations
126 * @param success Was the operation a success?
128 void purchaseCompleted( bool success );
132 * Adds all tracks with a common mood to the playlist
133 * @param mood The mood of the tracks to add
135 //void addMoodyTracksToPlaylist( QString mood );
139 * Checks if purchase button should be enabled
140 * @param selection the new selection
141 * @param deseleted items that were previously selected but have been deselected
143 void itemSelected( CollectionTreeItem * selectedItem );
145 private:
147 * Helper function that initializes the button panel below the list view
149 void initBottomPanel();
152 * Helper function that initializes the genre selection panel above the list view
154 void initTopPanel();
157 * Starts downloading an updated track list xml file from
158 * http://magnatune.com/info/album_info.xml
159 * @return Currently always returns true
161 bool updateMagnatuneList();
164 * Adds a magnatune preview track to the playlist.
165 * @param item The track to add
167 //void addTrackToPlaylist ( Meta::MagnatuneTrack *item );
169 static MagnatuneStore *s_instance;
171 QString m_currentInfoUrl;
172 QMenu *m_popupMenu;
173 MagnatunePurchaseHandler *m_purchaseHandler;
174 MagnatuneRedownloadHandler *m_redownloadHandler;
176 QPushButton *m_advancedFeaturesButton;
177 QPushButton *m_updateListButton;
178 QPushButton *m_purchaseAlbumButton;
179 QPushButton *m_showInfoToggleButton;
181 QComboBox *m_genreComboBox;
182 bool m_purchaseInProgress;
184 Meta::MagnatuneAlbum * m_currentAlbum;
187 KIO::FileCopyJob * m_listDownloadJob;
189 ServiceSqlCollection * m_collection;
191 QString m_tempFileName;
196 #endif