Clementine Adore Mod
 All Classes Namespaces Files Functions Variables Macros Pages
adoreservice.h
Go to the documentation of this file.
1 /* This file is part of Clementine.
2  Copyright 2009-2013, David Sansome <me@davidsansome.com>
3  Copyright 2010-2012, 2014, John Maguire <john.maguire@gmail.com>
4  Copyright 2011, Andrea Decorte <adecorte@gmail.com>
5  Copyright 2012, Kacper "mattrick" Banasik <mattrick@jabster.pl>
6  Copyright 2012, Harald Sitter <sitter@kde.org>
7  Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
8  Copyright 2015, Thomas Mielke <thomas.mielke@c3s.cc>
9 
10  Clementine is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  Clementine is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with Clementine. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef INTERNET_LASTFM_ADORESERVICE_H_
25 #define INTERNET_LASTFM_ADORESERVICE_H_
26 
27 #include <memory>
28 
29 #include <QNetworkReply>
30 #include <QNetworkRequest>
31 #include <QAuthenticator>
32 
119 
130 namespace lastfm {
131 class Track;
132 }
133 
134 #include <QtGlobal>
135 uint qHash(const lastfm::Track& track);
136 
137 #include "adoredb.h"
138 #include "adorestreamer.h"
139 
140 #include "../lastfm/lastfmcompat.h"
141 
142 #include "internet/core/scrobbler.h"
143 
144 class Application;
145 class QNetworkAccessManager;
146 class Song;
147 
155 class AdoreService : public Scrobbler {
156  Q_OBJECT
157 
158  public:
159  explicit AdoreService(Application* app, QObject* parent = nullptr);
160  ~AdoreService();
161 
162  static const char* kServiceName;
163  static const char* kSettingsGroup;
164  static const char* kUrl;
165  static const int kPort;
166  static const char* kUtilizeImp;
167  static const char* kAuthorize;
168  static const char* kRegister;
169  static const char* kPlayerName;
170  static const char* kPluginVendor;
171  static const char* kPluginName;
172  static const char* kPluginVersion;
173 
174  void ReloadSettings();
175 
176  virtual QString Icon() { return ":providers/adore.png"; }
177 
178  // Last.fm specific stuff
179  bool IsAuthenticated() const;
180  bool IsScrobblingEnabled() const { return scrobbling_enabled_; }
181  bool AreButtonsVisible() const { return buttons_visible_; }
183  bool PreferAlbumArtist() const { return prefer_albumartist_; }
185 
186  void UpdateSubscriberStatus();
187 
188  public slots:
189  void NowPlaying(const Song& song);
190  void Scrobble();
191  void Love();
192  void Ban();
193  void ShowConfig();
194  void ToggleScrobbling();
195 
196  signals:
197  void AuthenticationComplete(bool success, const QString& error_message);
198 
199  void SavedItemsChanged();
200 
201  private slots:
202  void ProvideAuthenication(QNetworkReply *reply,QAuthenticator *auth); // just provided for the test site
203  void UtilizeImpReplyFinished(QNetworkReply* reply);
204  void RegisterClientReplyFinished(QNetworkReply* reply);
205 
206 
207  private:
208  QNetworkAccessManager* network_;
209  lastfm::Track TrackFromSong(const Song& song) const;
210  void RegisterClient();
211  void ProcessQueued();
212 
213  private:
214  lastfm::Audioscrobbler* scrobbler_;
215  lastfm::Track last_track_;
216  lastfm::Track next_metadata_;
217 
223 
224  Application* app_;
225 
226  // handy helper classes:
229 };
230 
231 #endif // INTERNET_LASTFM_ADORESERVICE_H_
bool prefer_albumartist_
remnant of the lastfm implementation. maybe use it in the future for better ui integration ...
Definition: adoreservice.h:221
lastfm::Track TrackFromSong(const Song &song) const
Converts a Clementine song to a lastfm track.
Definition: adoreservice.cpp:132
virtual QString Icon()
Definition: adoreservice.h:176
QNetworkAccessManager * network_
Definition: adoreservice.h:208
static const char * kServiceName
as appears in the settings window
Definition: adoreservice.h:162
Application * app_
Definition: adoreservice.h:224
void Ban()
This is a remnant of the scrobbler type service, maybe deploy an own type in the future...
Definition: adoreservice.cpp:394
bool IsScrobbleButtonVisible() const
Definition: adoreservice.h:182
static const char * kPluginName
as Clementine doesn't have a real plugin system, just translate it as ModName or PatchName ...
Definition: adoreservice.h:171
lastfm::Track next_metadata_
needed to keep track of the metadata.
Definition: adoreservice.h:216
static const char * kSettingsGroup
as appears in the settings navibar
Definition: adoreservice.h:163
bool connection_problems_
Useful to inform the user that we can't scrobble right now. remnant of the lastfm implementation...
Definition: adoreservice.h:222
void NowPlaying(const Song &song)
This is a remnant of the scrobbler type service, maybe deploy an own type in the future...
Definition: adoreservice.cpp:177
void UtilizeImpReplyFinished(QNetworkReply *reply)
Handle the clean-up of the reply to the RegisterClient API call.
Definition: adoreservice.cpp:326
This class handles the received audio buffers.
Definition: adorestreamer.h:33
bool buttons_visible_
remnant of the lastfm implementation. maybe use it in the future for better ui integration ...
Definition: adoreservice.h:219
void ProvideAuthenication(QNetworkReply *reply, QAuthenticator *auth)
this slot is just provided for handling the http authorisation of the test site – disable in AdoreSer...
Definition: adoreservice.cpp:105
bool HasConnectionProblems() const
Definition: adoreservice.h:184
void Love()
This is a remnant of the scrobbler type service, maybe deploy an own type in the future...
Definition: adoreservice.cpp:390
AdoreStreamer astreamer
GStreamer audio buffer grabber, converter to 11050 Hz mono, and fingerprinter.
Definition: adoreservice.h:228
void SavedItemsChanged()
This class handles SQLite access to the queue file.
Definition: adoredb.h:43
static const char * kRegister
path to the player client registration api call of the REST API (meant to submit some extra informati...
Definition: adoreservice.h:168
bool scrobbling_enabled_
remnant of the lastfm implementation. maybe use it in the future for better ui integration ...
Definition: adoreservice.h:218
void AuthenticationComplete(bool success, const QString &error_message)
remnant of the lastfm implementation. maybe use it in the future for better ui integration ...
bool scrobble_button_visible_
remnant of the lastfm implementation. maybe use it in the future for better ui integration ...
Definition: adoreservice.h:220
bool IsAuthenticated() const
Definition: adoreservice.cpp:124
static const char * kPluginVendor
the creator of the Adore code
Definition: adoreservice.h:170
AdoreService(Application *app, QObject *parent=nullptr)
Definition: adoreservice.cpp:84
void ProcessQueued()
Definition: adoreservice.cpp:262
void UpdateSubscriberStatus()
lastfm::Track last_track_
needed to keep track of the metadata.
Definition: adoreservice.h:215
void RegisterClientReplyFinished(QNetworkReply *reply)
Handle the clean-up of the reply to the RegisterClient API call.
Definition: adoreservice.cpp:169
void Scrobble()
This is a remnant of the scrobbler type service, maybe deploy an own type in the future...
Definition: adoreservice.cpp:386
bool PreferAlbumArtist() const
Definition: adoreservice.h:183
bool IsScrobblingEnabled() const
Definition: adoreservice.h:180
void ToggleScrobbling()
This is a remnant of the scrobbler type service, maybe deploy an own type in the future...
Definition: adoreservice.cpp:398
static const int kPort
port of the REST API, can be overridden in ~/.config/Clementine/Clementine.conf section [Adore] key '...
Definition: adoreservice.h:165
uint qHash(const lastfm::Track &track)
AdoreDb adb
SQLite db for batch processing.
Definition: adoreservice.h:227
static const char * kUtilizeImp
path to the utilization api call of the REST API
Definition: adoreservice.h:166
bool AreButtonsVisible() const
Definition: adoreservice.h:181
The central class of the Adore mod, controlling all other AdoreXXX classes.
Definition: adoreservice.h:155
static const char * kUrl
URL of the REST API, can be overridden in ~/.config/Clementine/Clementine.conf section [Adore] key 'h...
Definition: adoreservice.h:164
static const char * kPlayerName
self explanatory
Definition: adoreservice.h:169
lastfm::Audioscrobbler * scrobbler_
zombie base object. remnant of the lastfm implementation.
Definition: adoreservice.h:214
static const char * kAuthorize
base path to the authorization web page
Definition: adoreservice.h:167
void RegisterClient()
Definition: adoreservice.cpp:145
~AdoreService()
Definition: adoreservice.cpp:102
void ReloadSettings()
preserved for future use, does nothing i.t.m.
Definition: adoreservice.cpp:112
static const char * kPluginVersion
version of the the Adore code
Definition: adoreservice.h:172
void ShowConfig()
This is a remnant of the scrobbler type service, maybe deploy an own type in the future...
Definition: adoreservice.cpp:117