spotify 7.0.4 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.yardopts CHANGED
@@ -1 +1 @@
1
- -e ./lib/yard-ffi.rb
1
+ -e ./lib/yard-ffi-plugin.rb
@@ -1,14 +1,17 @@
1
- libspotify FFI bindings for Ruby
2
- ================================
3
- [libspotify](http://developer.spotify.com/en/libspotify/overview/) is a C library which allows developers to interact with the Spotify music streaming service. I wanted to be able to use this library in Ruby, and thus [Hallon](https://github.com/Burgestrand/Hallon) was born. Hallon, however, is more than just bindings to libspotify, it’s my attempt to make the API a joy to use. This is Ruby, after all!
1
+ Ruby FFI bindings for [libspotify][]
2
+ ====================================
4
3
 
5
- Hallon recently changed from being a C extension to using [Ruby FFI](https://github.com/ffi/ffi), and in the process I created libspotify for Ruby. I decided to extract that work into its’ own gem, and here it is.
4
+ The libspotify C API package allows third party developers to write
5
+ applications that utilize the Spotify music streaming service.
6
6
 
7
- This is a very primitive library!
8
- ---------------------------------
9
- There is no sugar-coating. When (if) you use this library you will practically be writing C, handling pointers and so on; only you’ll be doing it in Ruby.
7
+ [Spotify][] is a really nice music streaming service, and being able to interact with it in an API is awesome. However, because libspotify is a C library, writing applications with it is cumbersome and error-prone compared to doing it in Ruby. As I found myself needing to do this one day, knowing I’d rather not be writing it in C, this gem was born.
10
8
 
11
- If you want a library that is easier to use, have a look at [Hallon](https://github.com/Burgestrand/Hallon).
9
+ Spotify, the gem, is a thin layer of Ruby atop the [libspotify][] C library. It allows developers to use libspotify without writing a line of C, thanks to [Ruby FFI](https://rubygems.org/gems/ffi). Do note that there is no sugar-coating, and no attempts of abstraction will be made. If you want a library that is easier to use, you should have a look at [Hallon](https://github.com/Burgestrand/Hallon).
10
+
11
+ (anecdotal note: this code base was previously a part of Hallon, but I decided to extract it and make a gem out of it)
12
+
13
+ [libspotify]: http://developer.spotify.com/en/libspotify/overview/
14
+ [Spotify]: https://www.spotify.com/
12
15
 
13
16
  Need help installing libspotify?
14
17
  --------------------------------
@@ -42,7 +42,7 @@ module Spotify
42
42
 
43
43
  #
44
44
  enum :sampletype, [:int16_native_endian]
45
- enum :bitrate, %w(160k 320k)
45
+ enum :bitrate, %w(160k 320k 96k).map(&:to_sym)
46
46
 
47
47
  # FFI::Struct for Audio Format.
48
48
  #
@@ -71,9 +71,19 @@ module Spotify
71
71
 
72
72
  #
73
73
  enum :connectionstate, [:logged_out, :logged_in, :disconnected, :undefined]
74
+
75
+ #
76
+ enum :connection_type, [:unknown, :none, :mobile, :mobile_roaming, :wifi, :wired]
77
+
78
+ #
79
+ enum :connection_rules, [:network , 0x1,
80
+ :network_if_roaming , 0x2,
81
+ :allow_sync_over_mobile, 0x4,
82
+ :allow_sync_over_wifi , 0x8]
74
83
 
75
84
  attach_function :session_create, :sp_session_create, [ :pointer, :pointer ], :error
76
85
  attach_function :session_release, :sp_session_release, [ :pointer ], :void
86
+
77
87
  attach_function :session_login, :sp_session_login, [ :pointer, :string, :string ], :void
78
88
  attach_function :session_user, :sp_session_user, [ :pointer ], :pointer
79
89
  attach_function :session_logout, :sp_session_logout, [ :pointer ], :void
@@ -94,6 +104,15 @@ module Spotify
94
104
  attach_function :session_preferred_bitrate, :sp_session_preferred_bitrate, [ :pointer, :bitrate ], :void
95
105
  attach_function :session_num_friends, :sp_session_num_friends, [ :pointer ], :int
96
106
  attach_function :session_friend, :sp_session_friend, [ :pointer, :int ], :pointer
107
+
108
+ attach_function :session_set_connection_type, :sp_session_set_connection_type, [ :pointer, :pointer ], :void
109
+ attach_function :session_set_connection_rules, :sp_session_set_connection_rules, [ :pointer, :pointer ], :void
110
+ attach_function :offline_tracks_to_sync, :sp_offline_tracks_to_sync, [ :pointer ], :int
111
+ attach_function :offline_num_playlists, :sp_offline_num_playlists, [ :pointer ], :int
112
+ attach_function :offline_sync_get_status, :sp_offline_sync_get_status, [ :pointer, :pointer ], :void
113
+ attach_function :session_user_country, :sp_session_user_country, [ :pointer ], :int
114
+ attach_function :session_preferred_offline_bitrate, :sp_session_preferred_offline_bitrate, [ :pointer, :bitrate, :bool ], :void
115
+
97
116
 
98
117
  # FFI::Struct for Session callbacks.
99
118
  #
@@ -112,6 +131,7 @@ module Spotify
112
131
  # @attr [callback(:pointer):void] start_playback
113
132
  # @attr [callback(:pointer):void] stop_playback
114
133
  # @attr [callback(:pointer, :pointer):void] get_audio_buffer_stats
134
+ # @attr [callback(:pointer)::void] offline_status_updated
115
135
  class SessionCallbacks < FFI::Struct
116
136
  layout :logged_in, callback([ :pointer, :error ], :void),
117
137
  :logged_out, callback([ :pointer ], :void),
@@ -127,7 +147,8 @@ module Spotify
127
147
  :userinfo_updated, callback([ :pointer ], :void),
128
148
  :start_playback, callback([ :pointer ], :void),
129
149
  :stop_playback, callback([ :pointer ], :void),
130
- :get_audio_buffer_stats, callback([ :pointer, :pointer ], :void)
150
+ :get_audio_buffer_stats, callback([ :pointer, :pointer ], :void),
151
+ :offline_status_updated, callback([ :pointer ], :void)
131
152
  end
132
153
 
133
154
  # FFI::Struct for Session configuration.
@@ -154,6 +175,29 @@ module Spotify
154
175
  :dont_save_metadata_for_playlists, :int,
155
176
  :initially_unload_playlists, :int
156
177
  end
178
+
179
+ # FFI::Struct for Offline Sync Status
180
+ #
181
+ # @attr [Fixnum] queued_tracks
182
+ # @attr [Fixnum] queued_bytes
183
+ # @attr [Fixnum] done_tracks
184
+ # @attr [Fixnum] done_bytes
185
+ # @attr [Fixnum] copied_tracks
186
+ # @attr [Fixnum] copied_bytes
187
+ # @attr [Fixnum] willnotcopy_tracks
188
+ # @attr [Fixnum] error_tracks
189
+ # @attr [Fixnum] syncing
190
+ class OfflineSyncStatus < FFI::Struct
191
+ layout :queued_tracks, :int,
192
+ :queued_bytes, :uint64,
193
+ :done_tracks, :int,
194
+ :done_bytes, :uint64,
195
+ :copied_tracks, :int,
196
+ :copied_bytes, :uint64,
197
+ :willnotcopy_tracks, :int,
198
+ :error_tracks, :int,
199
+ :syncing, :int
200
+ end
157
201
 
158
202
  #
159
203
  # Link
@@ -162,7 +206,7 @@ module Spotify
162
206
 
163
207
  #
164
208
  enum :linktype, [:invalid, :track, :album, :artist, :search,
165
- :playlist, :profile, :starred, :localtrack]
209
+ :playlist, :profile, :starred, :localtrack, :image]
166
210
 
167
211
  attach_function :link_create_from_string, :sp_link_create_from_string, [ :string ], :pointer
168
212
  attach_function :link_create_from_track, :sp_link_create_from_track, [ :pointer, :int ], :pointer
@@ -170,6 +214,9 @@ module Spotify
170
214
  attach_function :link_create_from_artist, :sp_link_create_from_artist, [ :pointer ], :pointer
171
215
  attach_function :link_create_from_search, :sp_link_create_from_search, [ :pointer ], :pointer
172
216
  attach_function :link_create_from_playlist, :sp_link_create_from_playlist, [ :pointer ], :pointer
217
+ attach_function :link_create_from_artist_portrait, :sp_link_create_from_artist_portrait, [ :pointer, :int ], :pointer
218
+ attach_function :link_create_from_album_cover, :sp_link_create_from_album_cover, [ :pointer ], :pointer
219
+ attach_function :link_create_from_image, :sp_link_create_from_image, [ :pointer ], :pointer
173
220
  attach_function :link_create_from_user, :sp_link_create_from_user, [ :pointer ], :pointer
174
221
  attach_function :link_as_string, :sp_link_as_string, [ :pointer, :buffer_out, :int ], :int
175
222
  attach_function :link_type, :sp_link_type, [ :pointer ], :linktype
@@ -178,6 +225,7 @@ module Spotify
178
225
  attach_function :link_as_album, :sp_link_as_album, [ :pointer ], :pointer
179
226
  attach_function :link_as_artist, :sp_link_as_artist, [ :pointer ], :pointer
180
227
  attach_function :link_as_user, :sp_link_as_user, [ :pointer ], :pointer
228
+
181
229
  attach_function :link_add_ref, :sp_link_add_ref, [ :pointer ], :void
182
230
  attach_function :link_release, :sp_link_release, [ :pointer ], :void
183
231
 
@@ -203,6 +251,7 @@ module Spotify
203
251
  attach_function :track_disc, :sp_track_disc, [ :pointer ], :int
204
252
  attach_function :track_index, :sp_track_index, [ :pointer ], :int
205
253
  attach_function :localtrack_create, :sp_localtrack_create, [ :string, :string, :string, :int ], :pointer
254
+
206
255
  attach_function :track_add_ref, :sp_track_add_ref, [ :pointer ], :void
207
256
  attach_function :track_release, :sp_track_release, [ :pointer ], :void
208
257
 
@@ -221,6 +270,7 @@ module Spotify
221
270
  attach_function :album_name, :sp_album_name, [ :pointer ], :string
222
271
  attach_function :album_year, :sp_album_year, [ :pointer ], :int
223
272
  attach_function :album_type, :sp_album_type, [ :pointer ], :albumtype
273
+
224
274
  attach_function :album_add_ref, :sp_album_add_ref, [ :pointer ], :void
225
275
  attach_function :album_release, :sp_album_release, [ :pointer ], :void
226
276
 
@@ -240,6 +290,7 @@ module Spotify
240
290
  attach_function :albumbrowse_num_tracks, :sp_albumbrowse_num_tracks, [ :pointer ], :int
241
291
  attach_function :albumbrowse_track, :sp_albumbrowse_track, [ :pointer, :int ], :pointer
242
292
  attach_function :albumbrowse_review, :sp_albumbrowse_review, [ :pointer ], :string
293
+
243
294
  attach_function :albumbrowse_add_ref, :sp_albumbrowse_add_ref, [ :pointer ], :void
244
295
  attach_function :albumbrowse_release, :sp_albumbrowse_release, [ :pointer ], :void
245
296
 
@@ -251,6 +302,7 @@ module Spotify
251
302
  #
252
303
  attach_function :artist_name, :sp_artist_name, [ :pointer ], :string
253
304
  attach_function :artist_is_loaded, :sp_artist_is_loaded, [ :pointer ], :bool
305
+
254
306
  attach_function :artist_add_ref, :sp_artist_add_ref, [ :pointer ], :void
255
307
  attach_function :artist_release, :sp_artist_release, [ :pointer ], :void
256
308
 
@@ -273,6 +325,7 @@ module Spotify
273
325
  attach_function :artistbrowse_num_similar_artists, :sp_artistbrowse_num_similar_artists, [ :pointer ], :int
274
326
  attach_function :artistbrowse_similar_artist, :sp_artistbrowse_similar_artist, [ :pointer, :int ], :pointer
275
327
  attach_function :artistbrowse_biography, :sp_artistbrowse_biography, [ :pointer ], :string
328
+
276
329
  attach_function :artistbrowse_add_ref, :sp_artistbrowse_add_ref, [ :pointer ], :void
277
330
  attach_function :artistbrowse_release, :sp_artistbrowse_release, [ :pointer ], :void
278
331
 
@@ -293,6 +346,8 @@ module Spotify
293
346
  attach_function :image_format, :sp_image_format, [ :pointer ], :imageformat
294
347
  attach_function :image_data, :sp_image_data, [ :pointer, :pointer ], :pointer
295
348
  attach_function :image_image_id, :sp_image_image_id, [ :pointer ], :pointer
349
+ attach_function :image_create_from_link, :sp_image_create_from_link, [ :pointer, :pointer ], :pointer
350
+
296
351
  attach_function :image_add_ref, :sp_image_add_ref, [ :pointer ], :void
297
352
  attach_function :image_release, :sp_image_release, [ :pointer ], :void
298
353
 
@@ -338,6 +393,7 @@ module Spotify
338
393
  attach_function :search_total_tracks, :sp_search_total_tracks, [ :pointer ], :int
339
394
  attach_function :search_total_albums, :sp_search_total_albums, [ :pointer ], :int
340
395
  attach_function :search_total_artists, :sp_search_total_artists, [ :pointer ], :int
396
+
341
397
  attach_function :search_add_ref, :sp_search_add_ref, [ :pointer ], :void
342
398
  attach_function :search_release, :sp_search_release, [ :pointer ], :void
343
399
 
@@ -348,6 +404,9 @@ module Spotify
348
404
 
349
405
  #
350
406
  enum :playlist_type, [:playlist, :start_folder, :end_folder, :placeholder]
407
+
408
+ #
409
+ enum :playlist_offline_status, [:no, :yes, :downloading, :waiting]
351
410
 
352
411
  attach_function :playlist_is_loaded, :sp_playlist_is_loaded, [ :pointer ], :bool
353
412
  attach_function :playlist_add_callbacks, :sp_playlist_add_callbacks, [ :pointer, :pointer, :pointer ], :void
@@ -378,6 +437,10 @@ module Spotify
378
437
  attach_function :playlist_is_in_ram, :sp_playlist_is_in_ram, [ :pointer, :pointer ], :bool
379
438
  attach_function :playlist_set_in_ram, :sp_playlist_set_in_ram, [ :pointer, :pointer, :bool ], :void
380
439
  attach_function :playlist_create, :sp_playlist_create, [ :pointer, :pointer ], :pointer
440
+ attach_function :playlist_get_offline_status, :sp_playlist_get_offline_status, [ :pointer, :pointer ], :playlist_offline_status
441
+ attach_function :playlist_get_offline_download_completed, :sp_playlist_get_offline_download_completed, [ :pointer, :pointer ], :playlist_offline_status
442
+ attach_function :playlist_set_offline_mode, :sp_playlist_set_offline_mode, [ :pointer, :pointer, :bool ], :void
443
+
381
444
  attach_function :playlist_add_ref, :sp_playlist_add_ref, [ :pointer ], :void
382
445
  attach_function :playlist_release, :sp_playlist_release, [ :pointer ], :void
383
446
 
@@ -439,6 +502,8 @@ module Spotify
439
502
  attach_function :playlistcontainer_move_playlist, :sp_playlistcontainer_move_playlist, [ :pointer, :int, :int, :bool ], :error
440
503
  attach_function :playlistcontainer_add_folder, :sp_playlistcontainer_add_folder, [ :pointer, :int, :string ], :error
441
504
  attach_function :playlistcontainer_owner, :sp_playlistcontainer_owner, [ :pointer ], :pointer
505
+ attach_function :playlistcontainer_is_loaded, :sp_playlistcontainer_is_loaded, [ :pointer ], :bool
506
+
442
507
  attach_function :playlistcontainer_add_ref, :sp_playlistcontainer_add_ref, [ :pointer ], :void
443
508
  attach_function :playlistcontainer_release, :sp_playlistcontainer_release, [ :pointer ], :void
444
509
 
@@ -469,6 +534,7 @@ module Spotify
469
534
  attach_function :user_full_name, :sp_user_full_name, [ :pointer ], :string
470
535
  attach_function :user_picture, :sp_user_picture, [ :pointer ], :string
471
536
  attach_function :user_relation_type, :sp_user_relation_type, [ :pointer, :pointer ], :relation_type
537
+
472
538
  attach_function :user_add_ref, :sp_user_add_ref, [ :pointer ], :void
473
539
  attach_function :user_release, :sp_user_release, [ :pointer ], :void
474
540
 
@@ -484,14 +550,15 @@ module Spotify
484
550
  attach_function :toplistbrowse_create, :sp_toplistbrowse_create, [ :pointer, :toplisttype, :toplistregion, :string, callback([:pointer, :pointer], :void), :pointer ], :pointer
485
551
  attach_function :toplistbrowse_is_loaded, :sp_toplistbrowse_is_loaded, [ :pointer ], :bool
486
552
  attach_function :toplistbrowse_error, :sp_toplistbrowse_error, [ :pointer ], :error
487
- attach_function :toplistbrowse_add_ref, :sp_toplistbrowse_add_ref, [ :pointer ], :void
488
- attach_function :toplistbrowse_release, :sp_toplistbrowse_release, [ :pointer ], :void
489
553
  attach_function :toplistbrowse_num_artists, :sp_toplistbrowse_num_artists, [ :pointer ], :int
490
554
  attach_function :toplistbrowse_artist, :sp_toplistbrowse_artist, [ :pointer, :int ], :pointer
491
555
  attach_function :toplistbrowse_num_albums, :sp_toplistbrowse_num_albums, [ :pointer ], :int
492
556
  attach_function :toplistbrowse_album, :sp_toplistbrowse_album, [ :pointer, :int ], :pointer
493
557
  attach_function :toplistbrowse_num_tracks, :sp_toplistbrowse_num_tracks, [ :pointer ], :int
494
558
  attach_function :toplistbrowse_track, :sp_toplistbrowse_track, [ :pointer, :int ], :pointer
559
+
560
+ attach_function :toplistbrowse_add_ref, :sp_toplistbrowse_add_ref, [ :pointer ], :void
561
+ attach_function :toplistbrowse_release, :sp_toplistbrowse_release, [ :pointer ], :void
495
562
 
496
563
  #
497
564
  # Inbox
@@ -501,6 +568,7 @@ module Spotify
501
568
  #
502
569
  attach_function :inbox_post_tracks, :sp_inbox_post_tracks, [ :pointer, :string, :pointer, :int, :string, callback([:pointer, :pointer], :void), :pointer ], :pointer
503
570
  attach_function :inbox_error, :sp_inbox_error, [ :pointer ], :error
571
+
504
572
  attach_function :inbox_add_ref, :sp_inbox_add_ref, [ :pointer ], :void
505
573
  attach_function :inbox_release, :sp_inbox_release, [ :pointer ], :void
506
574
  end
@@ -1,3 +1,3 @@
1
1
  module Spotify
2
- VERSION = [7, 0, 4].join('.')
2
+ VERSION = [8, 0, 0].join('.')
3
3
  end
File without changes
data/spec/api.h CHANGED
@@ -147,7 +147,7 @@ SP_LIBEXPORT(const char*) sp_error_message(sp_error error);
147
147
  * returned from sp_session_create(). Future versions of the library will provide you with some kind of mechanism
148
148
  * to request an updated version of the library.
149
149
  */
150
- #define SPOTIFY_API_VERSION 7
150
+ #define SPOTIFY_API_VERSION 8
151
151
 
152
152
  /**
153
153
  * Describes the current state of the connection
@@ -182,6 +182,7 @@ typedef struct sp_audioformat {
182
182
  typedef enum sp_bitrate {
183
183
  SP_BITRATE_160k = 0,
184
184
  SP_BITRATE_320k = 1,
185
+ SP_BITRATE_96k = 2,
185
186
  } sp_bitrate;
186
187
 
187
188
  /**
@@ -194,6 +195,16 @@ typedef enum sp_playlist_type {
194
195
  SP_PLAYLIST_TYPE_PLACEHOLDER = 3, ///< Unknown entry.
195
196
  } sp_playlist_type;
196
197
 
198
+ /*
199
+ * Playlist offline status
200
+ */
201
+ typedef enum sp_playlist_offline_status {
202
+ SP_PLAYLIST_OFFLINE_STATUS_NO = 0, ///< Playlist is not offline enabled
203
+ SP_PLAYLIST_OFFLINE_STATUS_YES = 1, ///< Playlist is synchronized to local storage
204
+ SP_PLAYLIST_OFFLINE_STATUS_DOWNLOADING = 2, ///< This playlist is currently downloading. Only one playlist can be in this state any given time
205
+ SP_PLAYLIST_OFFLINE_STATUS_WAITING = 3, ///< Playlist is queued for download
206
+ } sp_playlist_offline_status;
207
+
197
208
  /**
198
209
  * Buffer stats used by get_audio_buffer_stats callback
199
210
  */
@@ -211,6 +222,79 @@ typedef struct sp_subscribers {
211
222
  } sp_subscribers;
212
223
 
213
224
 
225
+ /**
226
+ * Current connection type set using sp_session_set_connection_type()
227
+ */
228
+ typedef enum sp_connection_type {
229
+ SP_CONNECTION_TYPE_UNKNOWN = 0, ///< Connection type unknown (Default)
230
+ SP_CONNECTION_TYPE_NONE = 1, ///< No connection
231
+ SP_CONNECTION_TYPE_MOBILE = 2, ///< Mobile data (EDGE, 3G, etc)
232
+ SP_CONNECTION_TYPE_MOBILE_ROAMING = 3, ///< Roamed mobile data (EDGE, 3G, etc)
233
+ SP_CONNECTION_TYPE_WIFI = 4, ///< Wireless connection
234
+ SP_CONNECTION_TYPE_WIRED = 5, ///< Ethernet cable, etc
235
+ } sp_connection_type;
236
+
237
+
238
+ /**
239
+ * Connection rules, bitwise OR of flags
240
+ *
241
+ * The default is SP_CONNECTION_RULE_NETWORK | SP_CONNECTION_RULE_ALLOW_SYNC
242
+ */
243
+ typedef enum sp_connection_rules {
244
+ SP_CONNECTION_RULE_NETWORK = 0x1, ///< Allow network traffic. When not set libspotify will force itself into offline mode
245
+ SP_CONNECTION_RULE_NETWORK_IF_ROAMING = 0x2, ///< Allow network traffic even if roaming
246
+ SP_CONNECTION_RULE_ALLOW_SYNC_OVER_MOBILE = 0x4, ///< Set to allow syncing of offline content over mobile connections
247
+ SP_CONNECTION_RULE_ALLOW_SYNC_OVER_WIFI = 0x8, ///< Set to allow syncing of offline content over WiFi
248
+ } sp_connection_rules;
249
+
250
+
251
+ /**
252
+ * Offline sync status
253
+ */
254
+ typedef struct sp_offline_sync_status {
255
+ /**
256
+ * Queued tracks/bytes is things left to sync in current sync
257
+ * operation
258
+ */
259
+ int queued_tracks;
260
+ sp_uint64 queued_bytes;
261
+
262
+ /**
263
+ * Done tracks/bytes is things marked for sync that existed on
264
+ * device before current sync operation
265
+ */
266
+ int done_tracks;
267
+ sp_uint64 done_bytes;
268
+
269
+ /**
270
+ * Copied tracks/bytes is things that has been copied in
271
+ * current sync operation
272
+ */
273
+ int copied_tracks;
274
+ sp_uint64 copied_bytes;
275
+
276
+ /**
277
+ * Tracks that are marked as synced but will not be copied
278
+ * (for various reasons)
279
+ */
280
+ int willnotcopy_tracks;
281
+
282
+ /**
283
+ * A track is counted as error when something goes wrong while
284
+ * syncing the track
285
+ */
286
+ int error_tracks;
287
+
288
+ /**
289
+ * Set if sync operation is in progress
290
+ */
291
+ bool syncing;
292
+
293
+ } sp_offline_sync_status;
294
+
295
+
296
+
297
+
214
298
  /**
215
299
  * Session callbacks
216
300
  *
@@ -404,6 +488,13 @@ typedef struct sp_session_callbacks {
404
488
  */
405
489
  void (SP_CALLCONV *get_audio_buffer_stats)(sp_session *session, sp_audio_buffer_stats *stats);
406
490
 
491
+ /**
492
+ * Called when offline synchronization status is updated
493
+ *
494
+ * @param[in] session Session
495
+ */
496
+ void (SP_CALLCONV *offline_status_updated)(sp_session *session);
497
+
407
498
  } sp_session_callbacks;
408
499
 
409
500
  /**
@@ -678,6 +769,18 @@ SP_LIBEXPORT(sp_playlistcontainer *) sp_session_publishedcontainer_for_user_crea
678
769
  */
679
770
  SP_LIBEXPORT(void) sp_session_preferred_bitrate(sp_session *session, sp_bitrate bitrate);
680
771
 
772
+
773
+ /**
774
+ * Set preferred bitrate for offline sync
775
+ *
776
+ * @param[in] session Session object
777
+ * @param[in] bitrate Preferred bitrate, see ::sp_bitrate for possible values
778
+ * @param[in] allow_resync Set to true if libspotify should resynchronize already synchronized tracks. Usually you should set this to false.
779
+ *
780
+ */
781
+ SP_LIBEXPORT(void) sp_session_preferred_offline_bitrate(sp_session *session, sp_bitrate bitrate, bool allow_resync);
782
+
783
+
681
784
  /**
682
785
  * Return number of friends in the currently logged in users friends list.
683
786
  *
@@ -699,6 +802,75 @@ SP_LIBEXPORT(int) sp_session_num_friends(sp_session *session);
699
802
  */
700
803
  SP_LIBEXPORT(sp_user *) sp_session_friend(sp_session *session, int index);
701
804
 
805
+
806
+ /**
807
+ * Set to true if the connection is currently routed over a roamed connectivity
808
+ *
809
+ * @param[in] session Session object
810
+ * @param[in] type Connection type
811
+ *
812
+ * @note Used in conjunction with sp_session_set_connection_rules() to control
813
+ * how libspotify should behave in respect to network activity and offline
814
+ * synchronization.
815
+ */
816
+ SP_LIBEXPORT(void) sp_session_set_connection_type(sp_session *session, sp_connection_type type);
817
+
818
+
819
+ /**
820
+ * Set rules for how libspotify connects to Spotify servers and synchronizes offline content
821
+ *
822
+ * @param[in] session Session object
823
+ * @param[in] rules Connection rules
824
+ *
825
+ * @note Used in conjunction with sp_session_set_connection_type() to control
826
+ * how libspotify should behave in respect to network activity and offline
827
+ * synchronization.
828
+ */
829
+ SP_LIBEXPORT(void) sp_session_set_connection_rules(sp_session *session, sp_connection_rules rules);
830
+
831
+
832
+
833
+ /**
834
+ * Get total number of tracks that needs download before everything
835
+ * from all playlists that is marked for offline is fully synchronized
836
+ *
837
+ * @param[in] session Session object
838
+ *
839
+ * @return Number of tracks
840
+ */
841
+ SP_LIBEXPORT(int) sp_offline_tracks_to_sync(sp_session *session);
842
+
843
+ /**
844
+ * Return number of playlisys that is marked for offline synchronization
845
+ *
846
+ * @param[in] session Session object
847
+ *
848
+ * @return Number of playlists
849
+ */
850
+ SP_LIBEXPORT(int) sp_offline_num_playlists(sp_session *session);
851
+
852
+ /**
853
+ * Return offline synchronization status. When the internal status is
854
+ * updated the offline_status_updated() callback will be invoked.
855
+ *
856
+ * @param[in] session Session object
857
+ * @param[out] status Status object that will be filled with info
858
+ *
859
+ */
860
+ SP_LIBEXPORT(void) sp_offline_sync_get_status(sp_session *session, sp_offline_sync_status *status);
861
+
862
+ /**
863
+ * Get currently logged in users country
864
+ * updated the offline_status_updated() callback will be invoked.
865
+ *
866
+ * @param[in] session Session object
867
+ *
868
+ * @return Country encoded in an integer 'SE' = 'S' << 8 | 'E'
869
+ */
870
+ SP_LIBEXPORT(int) sp_session_user_country(sp_session *session);
871
+
872
+
873
+
702
874
  /** @} */
703
875
 
704
876
 
@@ -723,6 +895,7 @@ typedef enum {
723
895
  SP_LINKTYPE_PROFILE = 6, ///< Link type is profile
724
896
  SP_LINKTYPE_STARRED = 7, ///< Link type is starred
725
897
  SP_LINKTYPE_LOCALTRACK = 8, ///< Link type is a local file
898
+ SP_LINKTYPE_IMAGE = 9, ///< Link type is an image
726
899
  } sp_linktype;
727
900
 
728
901
  /**
@@ -764,6 +937,18 @@ SP_LIBEXPORT(sp_link *) sp_link_create_from_track(sp_track *track, int offset);
764
937
  */
765
938
  SP_LIBEXPORT(sp_link *) sp_link_create_from_album(sp_album *album);
766
939
 
940
+ /**
941
+ * Create an image link object from an album
942
+ *
943
+ * @param[in] album An album object
944
+ *
945
+ * @return A link representing the album cover. Type is set to SP_LINKTYPE_IMAGE
946
+ *
947
+ * @note You need to release the link when you are done with it.
948
+ * @see sp_link_release()
949
+ */
950
+ SP_LIBEXPORT(sp_link *) sp_link_create_from_album_cover(sp_album *album);
951
+
767
952
  /**
768
953
  * Creates a link object from an artist
769
954
  *
@@ -776,6 +961,20 @@ SP_LIBEXPORT(sp_link *) sp_link_create_from_album(sp_album *album);
776
961
  */
777
962
  SP_LIBEXPORT(sp_link *) sp_link_create_from_artist(sp_artist *artist);
778
963
 
964
+ /**
965
+ * Creates a link object from an artist portrait
966
+ *
967
+ * @param[in] arb Artist browse object
968
+ * @param[in] index The index of the portrait. Should be in the interval [0, sp_artistbrowse_num_portraits() - 1]
969
+ *
970
+ * @return A link object representing an image
971
+ *
972
+ * @note You need to release the link when you are done with it.
973
+ * @see sp_link_release()
974
+ * @see sp_artistbrowse_num_portraits()
975
+ */
976
+ SP_LIBEXPORT(sp_link *) sp_link_create_from_artist_portrait(sp_artistbrowse *arb, int index);
977
+
779
978
  /**
780
979
  * Generate a link object representing the current search
781
980
  *
@@ -817,6 +1016,18 @@ SP_LIBEXPORT(sp_link *) sp_link_create_from_playlist(sp_playlist *playlist);
817
1016
  */
818
1017
  SP_LIBEXPORT(sp_link *) sp_link_create_from_user(sp_user *user);
819
1018
 
1019
+ /**
1020
+ * Create a link object representing the given image
1021
+ *
1022
+ * @param[in] image Image object
1023
+ *
1024
+ * @return A link representing the image.
1025
+ *
1026
+ * @note You need to release the link when you are done with it.
1027
+ * @see sp_link_release()
1028
+ */
1029
+ SP_LIBEXPORT(sp_link *) sp_link_create_from_image(sp_image *image);
1030
+
820
1031
  /**
821
1032
  * Create a string representation of the given Spotify link
822
1033
  *
@@ -1638,6 +1849,19 @@ typedef void SP_CALLCONV image_loaded_cb(sp_image *image, void *userdata);
1638
1849
  */
1639
1850
  SP_LIBEXPORT(sp_image *) sp_image_create(sp_session *session, const byte image_id[20]);
1640
1851
 
1852
+ /**
1853
+ * Create an image object from a link
1854
+ *
1855
+ * @param[in] session Session
1856
+ * @param[in] l Spotify link object. This must be of SP_LINKTYPE_IMAGE type
1857
+ *
1858
+ * @return Pointer to an image object. To free the object, use
1859
+ * sp_image_release()
1860
+ *
1861
+ * @see sp_image_create
1862
+ */
1863
+ SP_LIBEXPORT(sp_image *) sp_image_create_from_link(sp_session *session, sp_link *l);
1864
+
1641
1865
  /**
1642
1866
  * Add a callback that will be invoked when the image is loaded
1643
1867
  *
@@ -2480,6 +2704,41 @@ SP_LIBEXPORT(void) sp_playlist_set_in_ram(sp_session *session, sp_playlist *play
2480
2704
  */
2481
2705
  SP_LIBEXPORT(sp_playlist *) sp_playlist_create(sp_session *session, sp_link *link);
2482
2706
 
2707
+ /**
2708
+ * Mark a playlist to be synchronized for offline playback
2709
+ *
2710
+ * @param[in] session Session object
2711
+ * @param[in] playlist Playlist object
2712
+ * @param[in] offline True iff playlist should be offline, false otherwise
2713
+ */
2714
+ SP_LIBEXPORT(void) sp_playlist_set_offline_mode(sp_session *session, sp_playlist *playlist, bool offline);
2715
+
2716
+ /**
2717
+ * Get offline status for a playlist
2718
+ *
2719
+ * @param[in] session Session object
2720
+ * @param[in] playlist Playlist object
2721
+ *
2722
+ * @return sp_playlist_offline_status
2723
+ *
2724
+ * @see When in SP_PLAYLIST_OFFLINE_STATUS_DOWNLOADING mode the
2725
+ * sp_playlist_get_offline_download_completed() method can be used to query
2726
+ * progress of the download
2727
+ */
2728
+ SP_LIBEXPORT(sp_playlist_offline_status) sp_playlist_get_offline_status(sp_session *session, sp_playlist *playlist);
2729
+
2730
+ /**
2731
+ * Get download progress for an offline playlist
2732
+ *
2733
+ * @param[in] session Session object
2734
+ * @param[in] playlist Playlist object
2735
+ *
2736
+ * @return Value from 0 - 100 that indicates amount of playlist that is downloaded
2737
+ *
2738
+ * @see sp_playlist_offline_status()
2739
+ */
2740
+ SP_LIBEXPORT(int) sp_playlist_get_offline_download_completed(sp_session *session, sp_playlist *playlist);
2741
+
2483
2742
  /**
2484
2743
  * Increase the reference count of a playlist
2485
2744
  *
@@ -2587,6 +2846,17 @@ SP_LIBEXPORT(void) sp_playlistcontainer_remove_callbacks(sp_playlistcontainer *p
2587
2846
  */
2588
2847
  SP_LIBEXPORT(int) sp_playlistcontainer_num_playlists(sp_playlistcontainer *pc);
2589
2848
 
2849
+ /**
2850
+ * Return true if the playlistcontainer is fully loaded
2851
+ *
2852
+ * @param[in] pc Playlist container
2853
+ *
2854
+ * @return True if container is loaded
2855
+ *
2856
+ * @note The container_loaded callback will be invoked when this flips to true
2857
+ */
2858
+ SP_LIBEXPORT(bool) sp_playlistcontainer_is_loaded(sp_playlistcontainer *pc);
2859
+
2590
2860
  /**
2591
2861
  * Return a pointer to the playlist at a specific index
2592
2862
  *
@@ -1,12 +1,8 @@
1
- require 'rubygems' unless defined?(gem)
2
- gem 'minitest'
3
- require 'minitest/autorun'
4
- require 'minitest/spec'
5
-
6
- begin require 'minitest-rg'
7
- rescue LoadError; end
8
-
9
- require 'rbgccxml'
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ retry if require 'rubygems'
5
+ end
10
6
 
11
7
  #
12
8
  # Hooking FFI for extra introspection
@@ -31,7 +27,7 @@ module Spotify
31
27
  attr_reader :attached_methods
32
28
  end
33
29
 
34
- require 'spotify'
30
+ Bundler.require(:default, :development)
35
31
 
36
32
  #
37
33
  # Utility
@@ -80,9 +76,7 @@ end
80
76
  describe "enums" do
81
77
  API_H_XML.enumerations.each do |enum|
82
78
  attached_enum = Spotify.enum_type enum["name"].sub(/\Asp_/, '').to_sym
83
- original_enum = Hash[enum.values.map do |v|
84
- [v["name"].downcase, v["init"]]
85
- end]
79
+ original_enum = enum.values.map { |v| [v["name"].downcase, v["init"]] } # TODO: SP_BITRATE_X => X
86
80
 
87
81
  describe enum["name"] do
88
82
  it "should exist" do
@@ -90,10 +84,19 @@ describe "enums" do
90
84
  end
91
85
 
92
86
  it "should match the definition" do
93
- attached_enum.symbol_map.sort_by { |k, v| -k.to_s.size }.each do |(key, value)|
94
- k, v = original_enum.find { |x, _| x.match key.to_s }
95
- v.must_equal value.to_s
96
- original_enum.delete(k)
87
+ attached_enum_map = attached_enum.symbol_map
88
+ original_enum.each do |(name, value)|
89
+ a_name, a_value = attached_enum_map.find { |(n, v)| name.match n.to_s }
90
+ attached_enum_map.delete(a_name)
91
+
92
+ unless a_value.to_s == value.to_s
93
+ p enum["name"]
94
+ p [name, value]
95
+ p [a_name, a_value]
96
+ puts
97
+ end
98
+
99
+ a_value.to_s.must_equal value
97
100
  end
98
101
  end
99
102
  end
@@ -108,12 +111,12 @@ describe "structs" do
108
111
  struct["name"].gsub('_', '').match(/#{const}/i)
109
112
  end
110
113
 
114
+ attached_members = Spotify.const_get(attached_struct).members.map(&:to_s)
115
+
111
116
  describe struct["name"] do
112
117
  it "should contain the same attributes" do
113
- original_members = struct.variables.map(&:name)
114
-
115
- Spotify.const_get(attached_struct).members.each do |member|
116
- original_members.must_include member.to_s
118
+ struct.variables.map(&:name).each do |member|
119
+ attached_members.must_include member
117
120
  end
118
121
  end
119
122
  end
@@ -17,10 +17,11 @@ Gem::Specification.new do |gem|
17
17
  gem.version = Spotify::VERSION
18
18
  gem.platform = Gem::Platform::RUBY
19
19
 
20
- gem.requirements << 'libspotify, v0.0.7'
20
+ gem.requirements << 'libspotify, v0.0.8'
21
21
  gem.add_dependency 'ffi', '~> 1.0.0'
22
22
  gem.add_development_dependency 'yard'
23
23
  gem.add_development_dependency 'rbgccxml'
24
+ gem.add_development_dependency 'turn'
24
25
  gem.add_development_dependency 'minitest', '~> 2.0.0'
25
26
  gem.add_development_dependency 'bundler', '~> 1.0.0'
26
27
  end
metadata CHANGED
@@ -1,79 +1,93 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: spotify
3
- version: !ruby/object:Gem::Version
4
- version: 7.0.4
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 8.0.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Kim Burgestrand
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-04-20 00:00:00.000000000 +02:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2011-05-24 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: ffi
17
- requirement: &2156760220 !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
18
19
  none: false
19
- requirements:
20
+ requirements:
20
21
  - - ~>
21
- - !ruby/object:Gem::Version
22
+ - !ruby/object:Gem::Version
22
23
  version: 1.0.0
23
24
  type: :runtime
24
- prerelease: false
25
- version_requirements: *2156760220
26
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
27
  name: yard
28
- requirement: &2156759800 !ruby/object:Gem::Requirement
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
29
30
  none: false
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
34
35
  type: :development
35
- prerelease: false
36
- version_requirements: *2156759800
37
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
38
  name: rbgccxml
39
- requirement: &2156759340 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
40
41
  none: false
41
- requirements:
42
- - - ! '>='
43
- - !ruby/object:Gem::Version
44
- version: '0'
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
45
46
  type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: turn
46
50
  prerelease: false
47
- version_requirements: *2156759340
48
- - !ruby/object:Gem::Dependency
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
49
60
  name: minitest
50
- requirement: &2156758780 !ruby/object:Gem::Requirement
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
51
63
  none: false
52
- requirements:
64
+ requirements:
53
65
  - - ~>
54
- - !ruby/object:Gem::Version
66
+ - !ruby/object:Gem::Version
55
67
  version: 2.0.0
56
68
  type: :development
57
- prerelease: false
58
- version_requirements: *2156758780
59
- - !ruby/object:Gem::Dependency
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
60
71
  name: bundler
61
- requirement: &2156758160 !ruby/object:Gem::Requirement
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
62
74
  none: false
63
- requirements:
75
+ requirements:
64
76
  - - ~>
65
- - !ruby/object:Gem::Version
77
+ - !ruby/object:Gem::Version
66
78
  version: 1.0.0
67
79
  type: :development
68
- prerelease: false
69
- version_requirements: *2156758160
80
+ version_requirements: *id006
70
81
  description:
71
- email:
82
+ email:
72
83
  - kim@burgestrand.se
73
84
  executables: []
85
+
74
86
  extensions: []
87
+
75
88
  extra_rdoc_files: []
76
- files:
89
+
90
+ files:
77
91
  - .gemtest
78
92
  - .gitignore
79
93
  - .yardopts
@@ -83,37 +97,37 @@ files:
83
97
  - Rakefile
84
98
  - lib/spotify.rb
85
99
  - lib/spotify/version.rb
86
- - lib/yard-ffi.rb
100
+ - lib/yard-ffi-plugin.rb
87
101
  - spec/api.h
88
102
  - spec/spotify_spec.rb
89
103
  - spotify.gemspec
90
- has_rdoc: true
91
104
  homepage: https://github.com/Burgestrand/libspotify-ruby
92
- licenses:
105
+ licenses:
93
106
  - X11 License
94
107
  post_install_message:
95
108
  rdoc_options: []
96
- require_paths:
109
+
110
+ require_paths:
97
111
  - lib
98
- required_ruby_version: !ruby/object:Gem::Requirement
112
+ required_ruby_version: !ruby/object:Gem::Requirement
99
113
  none: false
100
- requirements:
101
- - - ! '>='
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: "0"
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
119
  none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- requirements:
111
- - libspotify, v0.0.7
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: "0"
124
+ requirements:
125
+ - libspotify, v0.0.8
112
126
  rubyforge_project:
113
- rubygems_version: 1.6.2
127
+ rubygems_version: 1.8.3
114
128
  signing_key:
115
129
  specification_version: 3
116
130
  summary: Bare-bones Ruby bindings for libspotify
117
- test_files:
131
+ test_files:
118
132
  - spec/api.h
119
133
  - spec/spotify_spec.rb