~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to src/internet/magnatuneservice.h

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of Clementine.
 
2
   Copyright 2010, David Sansome <me@davidsansome.com>
 
3
 
 
4
   Clementine is free software: you can redistribute it and/or modify
 
5
   it under the terms of the GNU General Public License as published by
 
6
   the Free Software Foundation, either version 3 of the License, or
 
7
   (at your option) any later version.
 
8
 
 
9
   Clementine is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
   GNU General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU General Public License
 
15
   along with Clementine.  If not, see <http://www.gnu.org/licenses/>.
 
16
*/
 
17
 
 
18
#ifndef MAGNATUNESERVICE_H
 
19
#define MAGNATUNESERVICE_H
 
20
 
 
21
#include <QXmlStreamReader>
 
22
 
 
23
#include "internetservice.h"
 
24
 
 
25
class QNetworkAccessManager;
 
26
class QSortFilterProxyModel;
 
27
class QMenu;
 
28
 
 
29
class LibraryBackend;
 
30
class LibraryModel;
 
31
class MagnatuneUrlHandler;
 
32
 
 
33
class MagnatuneService : public InternetService {
 
34
  Q_OBJECT
 
35
 
 
36
 public:
 
37
  MagnatuneService(InternetModel* parent);
 
38
  ~MagnatuneService();
 
39
 
 
40
  // Values are saved in QSettings and are indices into the combo box in
 
41
  // MagnatuneConfig
 
42
  enum MembershipType {
 
43
    Membership_None = 0,
 
44
    Membership_Streaming = 1,
 
45
    Membership_Download = 2,
 
46
  };
 
47
 
 
48
  // Values are saved in QSettings and are indices into the combo box in
 
49
  // MagnatuneConfig
 
50
  enum PreferredFormat {
 
51
    Format_Ogg = 0,
 
52
    Format_Flac = 1,
 
53
    Format_Wav = 2,
 
54
    Format_MP3_VBR = 3,
 
55
    Format_MP3_128 = 4,
 
56
  };
 
57
 
 
58
  static const char* kServiceName;
 
59
  static const char* kSettingsGroup;
 
60
  static const char* kDatabaseUrl;
 
61
  static const char* kSongsTable;
 
62
  static const char* kFtsTable;
 
63
  static const char* kHomepage;
 
64
  static const char* kStreamingHostname;
 
65
  static const char* kDownloadHostname;
 
66
  static const char* kPartnerId;
 
67
  static const char* kDownloadUrl;
 
68
 
 
69
  static QString ReadElementText(QXmlStreamReader& reader);
 
70
 
 
71
  QStandardItem* CreateRootItem();
 
72
  void LazyPopulate(QStandardItem* item);
 
73
 
 
74
  void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos);
 
75
 
 
76
  QWidget* HeaderWidget() const;
 
77
 
 
78
  void ReloadSettings();
 
79
 
 
80
  // Magnatune specific stuff
 
81
  MembershipType membership_type() const { return membership_; }
 
82
  PreferredFormat preferred_format() const { return format_; }
 
83
  QString username() const { return username_; }
 
84
  QString password() const { return password_; }
 
85
  LibraryBackend* library_backend() const { return library_backend_; }
 
86
 
 
87
  QUrl ModifyUrl(const QUrl& url) const;
 
88
 
 
89
 signals:
 
90
  void DownloadFinished(const QStringList& albums);
 
91
 
 
92
 protected:
 
93
  QModelIndex GetCurrentIndex();
 
94
 
 
95
 private slots:
 
96
  void UpdateTotalSongCount(int count);
 
97
  void ReloadDatabase();
 
98
  void ReloadDatabaseFinished();
 
99
 
 
100
  void Download();
 
101
  void Homepage();
 
102
  void ShowConfig();
 
103
 
 
104
 private:
 
105
  void EnsureMenuCreated();
 
106
 
 
107
  Song ReadTrack(QXmlStreamReader& reader);
 
108
 
 
109
 private:
 
110
  MagnatuneUrlHandler* url_handler_;
 
111
 
 
112
  QMenu* context_menu_;
 
113
  QModelIndex context_item_;
 
114
  QStandardItem* root_;
 
115
 
 
116
  QAction* download_;
 
117
 
 
118
  LibraryBackend* library_backend_;
 
119
  LibraryModel* library_model_;
 
120
  LibraryFilterWidget* library_filter_;
 
121
  QSortFilterProxyModel* library_sort_model_;
 
122
  int load_database_task_id_;
 
123
 
 
124
  MembershipType membership_;
 
125
  QString username_;
 
126
  QString password_;
 
127
  PreferredFormat format_;
 
128
 
 
129
  int total_song_count_;
 
130
 
 
131
  QNetworkAccessManager* network_;
 
132
};
 
133
 
 
134
#endif // MAGNATUNESERVICE_H