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

« back to all changes in this revision

Viewing changes to src/internet/spotifyserver.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 SPOTIFYSERVER_H
 
19
#define SPOTIFYSERVER_H
 
20
 
 
21
#include "spotifyblob/common/spotifymessages.pb.h"
 
22
 
 
23
#include <QImage>
 
24
#include <QObject>
 
25
 
 
26
class SpotifyMessageHandler;
 
27
 
 
28
class QTcpServer;
 
29
class QTcpSocket;
 
30
 
 
31
class SpotifyServer : public QObject {
 
32
  Q_OBJECT
 
33
 
 
34
public:
 
35
  SpotifyServer(QObject* parent = 0);
 
36
 
 
37
  void Init();
 
38
  void Login(const QString& username, const QString& password,
 
39
             spotify_pb::Bitrate bitrate, bool volume_normalisation);
 
40
 
 
41
  void LoadStarred();
 
42
  void SyncStarred();
 
43
  void LoadInbox();
 
44
  void SyncInbox();
 
45
  void LoadUserPlaylist(int index);
 
46
  void SyncUserPlaylist(int index);
 
47
  void StartPlaybackLater(const QString& uri, quint16 port);
 
48
  void Search(const QString& text, int limit, int limit_album = 0);
 
49
  void LoadImage(const QString& id);
 
50
  void AlbumBrowse(const QString& uri);
 
51
  void SetPlaybackSettings(spotify_pb::Bitrate bitrate, bool volume_normalisation);
 
52
 
 
53
  int server_port() const;
 
54
 
 
55
public slots:
 
56
  void StartPlayback(const QString& uri, quint16 port);
 
57
  void Seek(qint64 offset_bytes);
 
58
 
 
59
signals:
 
60
  void LoginCompleted(bool success, const QString& error,
 
61
                      spotify_pb::LoginResponse_Error error_code);
 
62
  void PlaylistsUpdated(const spotify_pb::Playlists& playlists);
 
63
 
 
64
  void StarredLoaded(const spotify_pb::LoadPlaylistResponse& response);
 
65
  void InboxLoaded(const spotify_pb::LoadPlaylistResponse& response);
 
66
  void UserPlaylistLoaded(const spotify_pb::LoadPlaylistResponse& response);
 
67
  void PlaybackError(const QString& message);
 
68
  void SearchResults(const spotify_pb::SearchResponse& response);
 
69
  void ImageLoaded(const QString& id, const QImage& image);
 
70
  void SyncPlaylistProgress(const spotify_pb::SyncPlaylistProgress& progress);
 
71
  void AlbumBrowseResults(const spotify_pb::BrowseAlbumResponse& response);
 
72
 
 
73
private slots:
 
74
  void NewConnection();
 
75
  void HandleMessage(const spotify_pb::SpotifyMessage& message);
 
76
 
 
77
private:
 
78
  void LoadPlaylist(spotify_pb::PlaylistType type, int index = -1);
 
79
  void SyncPlaylist(spotify_pb::PlaylistType type, int index, bool offline);
 
80
  void SendMessage(const spotify_pb::SpotifyMessage& message);
 
81
 
 
82
  QTcpServer* server_;
 
83
  QTcpSocket* protocol_socket_;
 
84
  SpotifyMessageHandler* handler_;
 
85
  bool logged_in_;
 
86
 
 
87
  QList<spotify_pb::SpotifyMessage> queued_login_messages_;
 
88
  QList<spotify_pb::SpotifyMessage> queued_messages_;
 
89
};
 
90
 
 
91
#endif // SPOTIFYSERVER_H