Sayonara Player
LastFM.h
1 /* LastFM.h */
2 
3 /* Copyright (C) 2011-2016 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 /*
23  * LastFM.h
24  *
25  * Created on: Apr 19, 2011
26  * Author: Lucio Carreras
27  */
28 
29 #ifndef LASTFM_H_
30 #define LASTFM_H_
31 
32 #include "Helper/Settings/SayonaraClass.h"
33 #include "Helper/MetaData/MetaData.h"
34 
35 #include <QMap>
36 #include <QtXml>
37 
38 
39 // singleton base LastFM API class
40 // signals and slots are handled by the adapter class
41 class PlayManager;
42 class LFMLoginThread;
44 class LastFM : public QObject, protected SayonaraClass{
45 
46  Q_OBJECT
47  SINGLETON(LastFM)
48 
49  signals:
50  void sig_logged_in(bool);
51 
52  public slots:
53  void psl_login();
54  void psl_logout();
55 
56 
57  private slots:
58  void sl_login_thread_finished(bool success);
59  void sl_similar_artists_available(IDList artist_ids);
60  void sl_track_changed(const MetaData&);
61  void sl_position_ms_changed(quint64);
62  void sl_scrobble_response(const QByteArray& data);
63  void sl_scrobble_error(const QString& str);
64 
65 
66  public:
67  bool is_logged_in();
68  static void get_login(QString& user, QString& pw);
69 
70 
71  private:
72 
73  LastFM(const LastFM&);
74  LastFM& operator=(const LastFM&);
75 
76 
77  bool _logged_in;
78  bool _active;
79  bool _scrobbled;
80 
81  QString _username;
82 
83  QString _auth_token;
84  QString _session_key;
85 
86  LFMTrackChangedThread* _track_changed_thread;
87  LFMLoginThread* _login_thread;
88 
89  PlayManager* _play_manager;
90 
91  quint64 _old_pos;
92  quint64 _old_pos_difference;
93 
94  MetaData _md;
95 
96 
97 
98 
99  bool init_track_changed_thread();
100  bool update_track(const MetaData&);
101  void get_similar_artists(const QString&);
102 
103 
104  void reset_scrobble();
105  bool check_scrobble(quint64 pos_ms);
106  void scrobble(const MetaData&);
107 
108 };
109 
110 #endif /* LASTFM_H_ */
Definition: LastFM.h:44
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:31
Definition: MetaData.h:49
Definition: LFMLoginThread.h:42
Global handler for current playback state (Singleton)
Definition: PlayManager.h:79
Definition: LFMTrackChangedThread.h:45