1 /***************************************************************************
2 * Copyright (c) 2006, 2007 *
3 * Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
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. *
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; 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
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"
36 #include <kio/jobclasses.h>
41 #include <q3popupmenu.h>
42 #include <QPushButton>
46 class MagnatuneServiceFactory
: public ServiceFactory
51 MagnatuneServiceFactory() {}
52 virtual ~MagnatuneServiceFactory() {}
55 virtual QString
name();
56 virtual KPluginInfo
info();
57 virtual KConfigGroup
config();
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
76 MagnatuneStore( const char *name
);
83 * Do not do expensive initializations before we are actually shown
86 // bool updateContextView();
91 * Slot called when the purchase album button is clicked. Starts a purchase
93 void purchaseButtonClicked();
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
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
);
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
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
;
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
;