summaryrefslogtreecommitdiffstats
path: root/amarok/src/magnatunebrowser/magnatunepurchasehandler.h
blob: 9889c66f5783358662436d0d44a51106851e1fd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
  Copyright (c) 2006  Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.

  You should have received a copy of the GNU Library General Public License
  along with this library; see the file COPYING.LIB.  If not, write to
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA 02110-1301, USA.
*/

#ifndef MAGNATUNEPURCHASEHANDLER_H
#define MAGNATUNEPURCHASEHANDLER_H

#include <tqobject.h>
#include <kio/job.h>
#include <kio/jobclasses.h>

#include "magnatunealbumdownloader.h"
#include "magnatunedownloaddialog.h"
#include "magnatunepurchasedialog.h"
#include "magnatunetypes.h"


/**
The main class responcible for handelig of purchases from Magnatune.com

@author Nikolaj Hald Nielsen
*/
class MagnatunePurchaseHandler : public QObject
{
Q_OBJECT
public:
    MagnatunePurchaseHandler();
    ~MagnatunePurchaseHandler();
    
   void setParent( TQWidget * parent );
   /**
    * Starts a purchase operation
    * @param album The album to purchase
    */
   void purchaseAlbum( const MagnatuneAlbum &album );

signals:

    void purchaseCompleted( bool success );

private:
    KIO::TransferJob * m_resultDownloadJob;


    //need a parent to pass to any dialogs we spawn
    TQWidget * m_parent;
    MagnatunePurchaseDialog * m_purchaseDialog;
    MagnatuneDownloadDialog * m_downloadDialog;
    MagnatuneAlbumDownloader * m_albumDownloader;
    MagnatuneAlbum m_currentAlbum;
    TQString m_currentAlbumCoverName;

    bool parseDownloadXml( TQString xml );

    /**
     * This function saves the xml download info received from Magnatune.com after a
     * successful payment. This information can be used to later redownload a lost album,
     * or acquire an album in a different file format. Note that no personal information
     * or credit card number is stored. The information is saved to the amarok config 
     * directory in the sub folder magnatune.com/purchases. The name of each info file 
     * is genereated from the artist and album names.
     * @param infoXml The info to store.
     */
    void saveDownloadInfo(TQString infoXml);


protected slots:

    void showPurchaseDialog( TQString coverTempLocation );
    void xmlDownloadComplete( KIO::Job* downLoadJob );
    void albumDownloadComplete(bool success);
    void albumPurchaseCancelled();

public slots:

    void processPayment( TQString ccNumber, TQString expYear, TQString expMonth, TQString name, TQString email, TQString albumCode, int amount );

    

};

#endif