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

« back to all changes in this revision

Viewing changes to src/radio/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 "radioservice.h"
24
 
 
25
 
class QNetworkAccessManager;
26
 
class QSortFilterProxyModel;
27
 
class QMenu;
28
 
 
29
 
class LibraryBackend;
30
 
class LibraryModel;
31
 
 
32
 
class MagnatuneService : public RadioService {
33
 
  Q_OBJECT
34
 
 
35
 
 public:
36
 
  MagnatuneService(RadioModel* parent);
37
 
  ~MagnatuneService();
38
 
 
39
 
  // Values are saved in QSettings and are indices into the combo box in
40
 
  // MagnatuneConfig
41
 
  enum MembershipType {
42
 
    Membership_None = 0,
43
 
    Membership_Streaming = 1,
44
 
    Membership_Download = 2,
45
 
  };
46
 
 
47
 
  // Values are saved in QSettings and are indices into the combo box in
48
 
  // MagnatuneConfig
49
 
  enum PreferredFormat {
50
 
    Format_Ogg = 0,
51
 
    Format_Flac = 1,
52
 
    Format_Wav = 2,
53
 
    Format_MP3_VBR = 3,
54
 
    Format_MP3_128 = 4,
55
 
  };
56
 
 
57
 
  static const char* kServiceName;
58
 
  static const char* kSettingsGroup;
59
 
  static const char* kDatabaseUrl;
60
 
  static const char* kSongsTable;
61
 
  static const char* kFtsTable;
62
 
  static const char* kHomepage;
63
 
  static const char* kStreamingHostname;
64
 
  static const char* kDownloadHostname;
65
 
  static const char* kPartnerId;
66
 
  static const char* kDownloadUrl;
67
 
 
68
 
  static QString ReadElementText(QXmlStreamReader& reader);
69
 
 
70
 
  QStandardItem* CreateRootItem();
71
 
  void LazyPopulate(QStandardItem* item);
72
 
 
73
 
  void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos);
74
 
 
75
 
  QWidget* HeaderWidget() const;
76
 
 
77
 
  void ReloadSettings();
78
 
 
79
 
  // Magnatune specific stuff
80
 
  MembershipType membership_type() const { return membership_; }
81
 
  PreferredFormat preferred_format() const { return format_; }
82
 
  QString username() const { return username_; }
83
 
  QString password() const { return password_; }
84
 
  LibraryBackend* library_backend() const { return library_backend_; }
85
 
 
86
 
  QUrl ModifyUrl(const QUrl& url) const;
87
 
 
88
 
 signals:
89
 
  void DownloadFinished(const QStringList& albums);
90
 
 
91
 
 protected:
92
 
  QModelIndex GetCurrentIndex();
93
 
 
94
 
 private slots:
95
 
  void UpdateTotalSongCount(int count);
96
 
  void ReloadDatabase();
97
 
  void ReloadDatabaseFinished();
98
 
 
99
 
  void Download();
100
 
  void Homepage();
101
 
  void ShowConfig();
102
 
 
103
 
 private:
104
 
  void EnsureMenuCreated();
105
 
 
106
 
  Song ReadTrack(QXmlStreamReader& reader);
107
 
 
108
 
 private:
109
 
  QMenu* context_menu_;
110
 
  QModelIndex context_item_;
111
 
  QStandardItem* root_;
112
 
 
113
 
  QAction* download_;
114
 
 
115
 
  LibraryBackend* library_backend_;
116
 
  LibraryModel* library_model_;
117
 
  LibraryFilterWidget* library_filter_;
118
 
  QSortFilterProxyModel* library_sort_model_;
119
 
  int load_database_task_id_;
120
 
 
121
 
  MembershipType membership_;
122
 
  QString username_;
123
 
  QString password_;
124
 
  PreferredFormat format_;
125
 
 
126
 
  int total_song_count_;
127
 
 
128
 
  QNetworkAccessManager* network_;
129
 
};
130
 
 
131
 
#endif // MAGNATUNESERVICE_H