Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

spotify: Upgrade to libspotify12

Added support for different sizes of images
  • Loading branch information...
commit 6b2bb91893d50cf66f3a08a17dfbc851a79822c3 1 parent b785d73
Magnus Röös authored
View
405 ext/spotify/api.h
@@ -43,7 +43,6 @@ extern "C" {
/* Includes */
#include <stddef.h>
-
#ifdef _WIN32
typedef unsigned __int64 sp_uint64;
#else
@@ -127,6 +126,9 @@ typedef enum sp_error {
SP_ERROR_OFFLINE_NOT_ALLOWED = 34, ///< This user is not allowed to use offline mode
SP_ERROR_OFFLINE_LICENSE_LOST = 35, ///< The license for this device has been lost. Most likely because the user used offline on three other device
SP_ERROR_OFFLINE_LICENSE_ERROR = 36, ///< The Spotify license server does not respond correctly
+ SP_ERROR_LASTFM_AUTH_ERROR = 39, ///< A LastFM scrobble authentication error has occurred
+ SP_ERROR_INVALID_ARGUMENT = 40, ///< An invalid argument was specified
+ SP_ERROR_SYSTEM_FAILURE = 41, ///< An operating system error
} sp_error;
/**
@@ -160,7 +162,7 @@ SP_LIBEXPORT(const char*) sp_error_message(sp_error error);
* returned from sp_session_create(). Future versions of the library will provide you with some kind of mechanism
* to request an updated version of the library.
*/
-#define SPOTIFY_API_VERSION 11
+#define SPOTIFY_API_VERSION 12
/**
* Describes the current state of the connection
@@ -254,6 +256,15 @@ typedef enum sp_track_offline_status {
} sp_track_offline_status;
/**
+ * Image size
+ */
+typedef enum sp_image_size {
+ SP_IMAGE_SIZE_NORMAL = 0, ///< Normal image size
+ SP_IMAGE_SIZE_SMALL = 1, ///< Small image size
+ SP_IMAGE_SIZE_LARGE = 2, ///< Large image size
+} sp_image_size;
+
+/**
* Buffer stats used by get_audio_buffer_stats callback
*/
typedef struct sp_audio_buffer_stats {
@@ -313,6 +324,20 @@ typedef enum sp_artistbrowse_type {
*/
} sp_artistbrowse_type;
+typedef enum sp_social_provider {
+ SP_SOCIAL_PROVIDER_SPOTIFY,
+ SP_SOCIAL_PROVIDER_FACEBOOK,
+ SP_SOCIAL_PROVIDER_LASTFM,
+} sp_social_provider;
+
+typedef enum sp_scrobbling_state {
+ SP_SCROBBLING_STATE_USE_GLOBAL_SETTING = 0,
+ SP_SCROBBLING_STATE_LOCAL_ENABLED = 1,
+ SP_SCROBBLING_STATE_LOCAL_DISABLED = 2,
+ SP_SCROBBLING_STATE_GLOBAL_ENABLED = 3,
+ SP_SCROBBLING_STATE_GLOBAL_DISABLED = 4,
+} sp_scrobbling_state;
+
/**
* Offline sync status
@@ -588,6 +613,28 @@ typedef struct sp_session_callbacks {
*/
void (SP_CALLCONV *credentials_blob_updated)(sp_session *session, const char *blob);
+ /**
+ * Called when the connection state has updated - such as when logging in, going offline, etc.
+ *
+ * @param[in] session Session
+ */
+ void (SP_CALLCONV *connectionstate_updated)(sp_session *session);
+
+ /**
+ * Called when there is a scrobble error event
+ *
+ * @param[in] session Session
+ * @param[in] error Scrobble error. Currently SP_ERROR_LASTFM_AUTH_ERROR.
+ */
+ void (SP_CALLCONV *scrobble_error)(sp_session *session, sp_error error);
+
+ /**
+ * Called when there is a change in the private session mode
+ *
+ * @param[in] session Session
+ * @param[in] isPrivate True if in private session, false otherwhise
+ */
+ void (SP_CALLCONV *private_session_mode_changed)(sp_session *session, bool is_private);
} sp_session_callbacks;
/**
@@ -639,6 +686,20 @@ typedef struct sp_session_config {
*/
const char *device_id;
+ /**
+ * Url to the proxy server that should be used.
+ * The format is protocol://<host>:port (where protocal is http/https/socks4/socks5)
+ */
+ const char *proxy;
+ /**
+ * Username to authenticate with proxy server
+ */
+ const char *proxy_username;
+ /**
+ * Password to authenticate with proxy server
+ */
+ const char *proxy_password;
+
/**
* Path to API trace file
@@ -674,8 +735,10 @@ SP_LIBEXPORT(sp_error) sp_session_create(const sp_session_config *config, sp_ses
* Release the session. This will clean up all data and connections associated with the session
*
* @param[in] sess Session object returned from sp_session_create()
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_release(sp_session *sess);
+SP_LIBEXPORT(sp_error) sp_session_release(sp_session *sess);
/**
@@ -696,8 +759,10 @@ SP_LIBEXPORT(void) sp_session_release(sp_session *sess);
* @param[in] remember_me If set, the username / password will be remembered by libspotify
* @param[in] blob If you have received a blob in the #credentials_blob_updated
* you can pas this here instead of password
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_login(sp_session *session, const char *username, const char *password, bool remember_me, const char *blob);
+SP_LIBEXPORT(sp_error) sp_session_login(sp_session *session, const char *username, const char *password, bool remember_me, const char *blob);
/**
@@ -730,12 +795,23 @@ SP_LIBEXPORT(int) sp_session_remembered_user(sp_session *session, char *buffer,
/**
+ * Get a pointer to a string representing the user's login username.
+ *
+ * @param[in] session Your session object
+ *
+ * @return A string representing the login username.
+ */
+SP_LIBEXPORT(const char *) sp_session_user_name(sp_session *session);
+
+
+/**
* Remove stored credentials in libspotify. If no credentials are currently stored, nothing will happen.
*
* @param[in] session Your session object
- *
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_forget_me(sp_session *session);
+SP_LIBEXPORT(sp_error) sp_session_forget_me(sp_session *session);
/**
@@ -754,8 +830,10 @@ SP_LIBEXPORT(sp_user *) sp_session_user(sp_session *session);
* logged in. Otherwise, the settings and cache may be lost.
*
* @param[in] session Your session object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_logout(sp_session *session);
+SP_LIBEXPORT(sp_error) sp_session_logout(sp_session *session);
/**
@@ -767,8 +845,10 @@ SP_LIBEXPORT(void) sp_session_logout(sp_session *session);
* should never need to be used.
*
* @param[in] session Your session object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_flush_caches(sp_session *session);
+SP_LIBEXPORT(sp_error) sp_session_flush_caches(sp_session *session);
/**
* The connection state of the specified session.
@@ -795,16 +875,20 @@ SP_LIBEXPORT(void *) sp_session_userdata(sp_session *session);
* @param[in] size Maximum cache size in megabytes.
* Setting it to 0 (the default) will let libspotify automatically
* resize the cache (10% of disk free space)
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_set_cache_size(sp_session *session, size_t size);
+SP_LIBEXPORT(sp_error) sp_session_set_cache_size(sp_session *session, size_t size);
/**
* Make the specified session process any pending events
*
* @param[in] session Your session object
* @param[out] next_timeout Stores the time (in milliseconds) until you should call this function again
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_process_events(sp_session *session, int *next_timeout);
+SP_LIBEXPORT(sp_error) sp_session_process_events(sp_session *session, int *next_timeout);
/**
* Loads the specified track
@@ -819,7 +903,6 @@ SP_LIBEXPORT(void) sp_session_process_events(sp_session *session, int *next_time
* @return One of the following errors, from ::sp_error
* SP_ERROR_OK
* SP_ERROR_MISSING_CALLBACK
- * SP_ERROR_RESOURCE_NOT_LOADED
* SP_ERROR_TRACK_NOT_PLAYABLE
*
*/
@@ -830,18 +913,20 @@ SP_LIBEXPORT(sp_error) sp_session_player_load(sp_session *session, sp_track *tra
*
* @param[in] session Your session object
* @param[in] offset Track position, in milliseconds.
- *
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_player_seek(sp_session *session, int offset);
+SP_LIBEXPORT(sp_error) sp_session_player_seek(sp_session *session, int offset);
/**
* Play or pause the currently loaded track
*
* @param[in] session Your session object
* @param[in] play If set to true, playback will occur. If set to false, the playback will be paused.
- *
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_player_play(sp_session *session, bool play);
+SP_LIBEXPORT(sp_error) sp_session_player_play(sp_session *session, bool play);
/**
* Stops the currently playing track
@@ -850,9 +935,10 @@ SP_LIBEXPORT(void) sp_session_player_play(sp_session *session, bool play);
* playing track.
*
* @param[in] session Your session object
- *
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_player_unload(sp_session *session);
+SP_LIBEXPORT(sp_error) sp_session_player_unload(sp_session *session);
/**
* Prefetch a track
@@ -935,9 +1021,11 @@ SP_LIBEXPORT(sp_playlistcontainer *) sp_session_publishedcontainer_for_user_crea
*
* @param[in] session Session object
* @param[in] bitrate Preferred bitrate, see ::sp_bitrate for possible values
- *
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
+ * SP_ERROR_INVALID_ARGUMENT
*/
-SP_LIBEXPORT(void) sp_session_preferred_bitrate(sp_session *session, sp_bitrate bitrate);
+SP_LIBEXPORT(sp_error) sp_session_preferred_bitrate(sp_session *session, sp_bitrate bitrate);
/**
@@ -946,9 +1034,11 @@ SP_LIBEXPORT(void) sp_session_preferred_bitrate(sp_session *session, sp_bitrate
* @param[in] session Session object
* @param[in] bitrate Preferred bitrate, see ::sp_bitrate for possible values
* @param[in] allow_resync Set to true if libspotify should resynchronize already synchronized tracks. Usually you should set this to false.
- *
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
+ * SP_ERROR_INVALID_ARGUMENT
*/
-SP_LIBEXPORT(void) sp_session_preferred_offline_bitrate(sp_session *session, sp_bitrate bitrate, bool allow_resync);
+SP_LIBEXPORT(sp_error) sp_session_preferred_offline_bitrate(sp_session *session, sp_bitrate bitrate, bool allow_resync);
/**
@@ -967,10 +1057,95 @@ SP_LIBEXPORT(bool) sp_session_get_volume_normalization(sp_session *session);
*
* @param[in] session Session object
* @param[in] on True iff volume normalization should be enabled
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
+ */
+SP_LIBEXPORT(sp_error) sp_session_set_volume_normalization(sp_session *session, bool on);
+
+
+/**
+ * Set if private session is enabled. This disables sharing what the user is listening to
+ * to services such as Spotify Social, Facebook and LastFM. The private session will
+ * last for a time, and then libspotify will revert to the normal state. The private
+ * session is prolonged by user activity.
+ *
+ * @param[in] session Session object
+ * @param[in] enabled True iff private session should be enabled
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
+ */
+SP_LIBEXPORT(sp_error) sp_session_set_private_session(sp_session *session, bool enabled);
+
+/**
+ * Return True if private session is enabled
+ *
+ * @param[in] session Session object
+ *
+ * @return True if private session is enabled
+ */
+SP_LIBEXPORT(bool) sp_session_is_private_session(sp_session *session);
+
+/**
+ * Set if scrobbling is enabled. This api allows setting local overrides of the global scrobbling settings.
+ * Changing the global settings are currently not supported.
+ *
+ * @param[in] session Session object
+ * @param[in] provider The scrobbling provider referred to
+ * @param[in] state The state to set the provider to
+ *
+ * @return error code
+ *
+ * @see sp_social_provider
+ * @see sp_scrobbling_state
+ */
+SP_LIBEXPORT(sp_error) sp_session_set_scrobbling(sp_session *session, sp_social_provider provider, sp_scrobbling_state state);
+
+/**
+ * Return the scrobbling state. This makes it possible to find out if scrobbling is locally overrided or
+ * if the global setting is used.
+ *
+ * @param[in] session Session object
+ * @param[in] provider The scrobbling provider referred to
+ * @param[out] state The output variable receiving the sp_scrobbling_state state
+ *
+ * @return error code
+ */
+SP_LIBEXPORT(sp_error) sp_session_is_scrobbling(sp_session *session, sp_social_provider provider, sp_scrobbling_state* state);
+
+/**
+ * Return True if scrobbling settings should be shown to the user. Currently this setting is relevant
+ * only to the facebook provider.
+ * The returned value may be false if the user is not connected to facebook,
+ * or if the user has opted out from facebook social graph.
*
+ * @param[in] session Session object
+ * @param[in] provider The scrobbling provider referred to
+ * @param[out] out True iff scrobbling is possible
+ *
+ * @return error code
*/
-SP_LIBEXPORT(void) sp_session_set_volume_normalization(sp_session *session, bool on);
+ SP_LIBEXPORT(sp_error) sp_session_is_scrobbling_possible(sp_session *session, sp_social_provider provider, bool* out);
+/**
+ * Set the user's credentials with a social provider.
+ * Currently this is only relevant for LastFm
+ * Call sp_session_set_scrobbling to force an authentication attempt
+ * with the LastFm server. If authentication fails a scrobble_error callback will be
+ * sent.
+ *
+ * @param[in] session Session object
+ * @param[in] provider The scrobbling provider referred to
+ * @param[in] username The user name
+ * @param[in] password The password
+ *
+ * @return error code
+
+ * @see sp_session_set_scrobbling
+ * @see sp_session_callbacks#scrobble_error
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
+ */
+SP_LIBEXPORT(sp_error) sp_session_set_social_credentials(sp_session *session, sp_social_provider provider, const char* username, const char* password);
/**
* Set to true if the connection is currently routed over a roamed connectivity
@@ -982,8 +1157,10 @@ SP_LIBEXPORT(void) sp_session_set_volume_normalization(sp_session *session, bool
* how libspotify should behave in respect to network activity and offline
* synchronization.
* @see sp_connection_type
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_set_connection_type(sp_session *session, sp_connection_type type);
+SP_LIBEXPORT(sp_error) sp_session_set_connection_type(sp_session *session, sp_connection_type type);
/**
@@ -996,8 +1173,10 @@ SP_LIBEXPORT(void) sp_session_set_connection_type(sp_session *session, sp_connec
* how libspotify should behave in respect to network activity and offline
* synchronization.
* @see sp_connection_rules
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_session_set_connection_rules(sp_session *session, sp_connection_rules rules);
+SP_LIBEXPORT(sp_error) sp_session_set_connection_rules(sp_session *session, sp_connection_rules rules);
@@ -1124,13 +1303,14 @@ SP_LIBEXPORT(sp_link *) sp_link_create_from_album(sp_album *album);
* Create an image link object from an album
*
* @param[in] album An album object
+ * @param[in] size The desired size of the image
*
* @return A link representing the album cover. Type is set to SP_LINKTYPE_IMAGE
*
* @note You need to release the link when you are done with it.
* @see sp_link_release()
*/
-SP_LIBEXPORT(sp_link *) sp_link_create_from_album_cover(sp_album *album);
+SP_LIBEXPORT(sp_link *) sp_link_create_from_album_cover(sp_album *album, sp_image_size size);
/**
* Creates a link object from an artist
@@ -1148,6 +1328,7 @@ SP_LIBEXPORT(sp_link *) sp_link_create_from_artist(sp_artist *artist);
* Creates a link object pointing to an artist portrait
*
* @param[in] artist Artist browse object
+ * @param[in] size The desired size of the image
*
* @return A link object representing an image
*
@@ -1155,7 +1336,7 @@ SP_LIBEXPORT(sp_link *) sp_link_create_from_artist(sp_artist *artist);
* @see sp_link_release()
* @see sp_artistbrowse_num_portraits()
*/
-SP_LIBEXPORT(sp_link *) sp_link_create_from_artist_portrait(sp_artist *artist);
+SP_LIBEXPORT(sp_link *) sp_link_create_from_artist_portrait(sp_artist *artist, sp_image_size size);
/**
@@ -1311,15 +1492,19 @@ SP_LIBEXPORT(sp_user *) sp_link_as_user(sp_link *link);
* Increase the reference count of a link
*
* @param[in] link The link object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_link_add_ref(sp_link *link);
+SP_LIBEXPORT(sp_error) sp_link_add_ref(sp_link *link);
/**
* Decrease the reference count of a link
*
* @param[in] link The link object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_link_release(sp_link *link);
+SP_LIBEXPORT(sp_error) sp_link_release(sp_link *link);
/** @} */
@@ -1458,7 +1643,7 @@ SP_LIBEXPORT(bool) sp_track_is_starred(sp_session *session, sp_track *track);
* @note This will fail silently if playlists are disabled.
* @see sp_set_playlists_enabled()
*/
-SP_LIBEXPORT(void) sp_track_set_starred(sp_session *session, sp_track *const*tracks, int num_tracks, bool star);
+SP_LIBEXPORT(sp_error) sp_track_set_starred(sp_session *session, sp_track *const*tracks, int num_tracks, bool star);
/**
* The number of artists performing on the specified track
@@ -1561,15 +1746,19 @@ SP_LIBEXPORT(sp_track *) sp_localtrack_create(const char *artist, const char *ti
* Increase the reference count of a track
*
* @param[in] track The track object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_track_add_ref(sp_track *track);
+SP_LIBEXPORT(sp_error) sp_track_add_ref(sp_track *track);
/**
* Decrease the reference count of a track
*
* @param[in] track The track object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_track_release(sp_track *track);
+SP_LIBEXPORT(sp_error) sp_track_release(sp_track *track);
/** @} */
@@ -1623,6 +1812,7 @@ SP_LIBEXPORT(sp_artist *) sp_album_artist(sp_album *album);
* Return image ID representing the album's coverart.
*
* @param[in] album Album object
+ * @param[in] size The desired size of the image
*
* @return ID byte sequence that can be passed to sp_image_create()
* If the album has no image or the metadata for the album is not
@@ -1630,7 +1820,7 @@ SP_LIBEXPORT(sp_artist *) sp_album_artist(sp_album *album);
*
* @see sp_image_create
*/
-SP_LIBEXPORT(const byte *) sp_album_cover(sp_album *album);
+SP_LIBEXPORT(const byte *) sp_album_cover(sp_album *album, sp_image_size size);
/**
* Return name of album
@@ -1667,15 +1857,19 @@ SP_LIBEXPORT(sp_albumtype) sp_album_type(sp_album *album);
* Increase the reference count of an album
*
* @param[in] album The album object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_album_add_ref(sp_album *album);
+SP_LIBEXPORT(sp_error) sp_album_add_ref(sp_album *album);
/**
* Decrease the reference count of an album
*
* @param[in] album The album object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_album_release(sp_album *album);
+SP_LIBEXPORT(sp_error) sp_album_release(sp_album *album);
/** @} */
@@ -1710,28 +1904,33 @@ SP_LIBEXPORT(bool) sp_artist_is_loaded(sp_artist *artist);
/**
* Return portrait for artist
*
- * @param[in] artist The artist object
+ * @param[in] artist The artist object
+ * @param[in] size The desired size of the image
*
* @return ID byte sequence that can be passed to sp_image_create()
* If the artist has no image or the metadata for the album is not
* loaded yet, this function returns NULL.
*
*/
-SP_LIBEXPORT(const byte *) sp_artist_portrait(sp_artist *artist);
+SP_LIBEXPORT(const byte *) sp_artist_portrait(sp_artist *artist, sp_image_size size);
/**
* Increase the reference count of a artist
*
* @param[in] artist The artist object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_artist_add_ref(sp_artist *artist);
+SP_LIBEXPORT(sp_error) sp_artist_add_ref(sp_artist *artist);
/**
* Decrease the reference count of a artist
*
* @param[in] artist The artist object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_artist_release(sp_artist *artist);
+SP_LIBEXPORT(sp_error) sp_artist_release(sp_artist *artist);
/** @} */
@@ -1882,15 +2081,19 @@ SP_LIBEXPORT(int) sp_albumbrowse_backend_request_duration(sp_albumbrowse *alb);
* Increase the reference count of an album browse result
*
* @param[in] alb The album browse result object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_albumbrowse_add_ref(sp_albumbrowse *alb);
+SP_LIBEXPORT(sp_error) sp_albumbrowse_add_ref(sp_albumbrowse *alb);
/**
* Decrease the reference count of an album browse result
*
* @param[in] alb The album browse result object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_albumbrowse_release(sp_albumbrowse *alb);
+SP_LIBEXPORT(sp_error) sp_albumbrowse_release(sp_albumbrowse *alb);
/** @} */
@@ -2102,15 +2305,19 @@ SP_LIBEXPORT(int) sp_artistbrowse_backend_request_duration(sp_artistbrowse *arb)
* Increase the reference count of an artist browse result
*
* @param[in] arb The artist browse result object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_artistbrowse_add_ref(sp_artistbrowse *arb);
+SP_LIBEXPORT(sp_error) sp_artistbrowse_add_ref(sp_artistbrowse *arb);
/**
* Decrease the reference count of an artist browse result
*
* @param[in] arb The artist browse result object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_artistbrowse_release(sp_artistbrowse *arb);
+SP_LIBEXPORT(sp_error) sp_artistbrowse_release(sp_artistbrowse *arb);
/** @} */
@@ -2174,7 +2381,7 @@ SP_LIBEXPORT(sp_image *) sp_image_create_from_link(sp_session *session, sp_link
* @param[in] userdata Opaque pointer passed to \p callback
*
*/
-SP_LIBEXPORT(void) sp_image_add_load_callback(sp_image *image, image_loaded_cb *callback, void *userdata);
+SP_LIBEXPORT(sp_error) sp_image_add_load_callback(sp_image *image, image_loaded_cb *callback, void *userdata);
/**
* Remove an image load callback previously added with sp_image_add_load_callback()
@@ -2183,9 +2390,10 @@ SP_LIBEXPORT(void) sp_image_add_load_callback(sp_image *image, image_loaded_cb *
* @param[in] callback Callback that will not be called when image has been
* fetched.
* @param[in] userdata Opaque pointer passed to \p callback
- *
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_image_remove_load_callback(sp_image *image, image_loaded_cb *callback, void *userdata);
+SP_LIBEXPORT(sp_error) sp_image_remove_load_callback(sp_image *image, image_loaded_cb *callback, void *userdata);
/**
* Check if an image is loaded. Before the image is loaded, the rest of the
@@ -2244,15 +2452,19 @@ SP_LIBEXPORT(const byte *) sp_image_image_id(sp_image *image);
* Increase the reference count of an image
*
* @param[in] image The image object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_image_add_ref(sp_image *image);
+SP_LIBEXPORT(sp_error) sp_image_add_ref(sp_image *image);
/**
* Decrease the reference count of an image
*
* @param[in] image The image object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_image_release(sp_image *image);
+SP_LIBEXPORT(sp_error) sp_image_release(sp_image *image);
/** @} */
@@ -2466,18 +2678,33 @@ SP_LIBEXPORT(int) sp_search_total_albums(sp_search *search);
SP_LIBEXPORT(int) sp_search_total_artists(sp_search *search);
/**
+ * Return the total number of playlists for the search query - regardless of the interval requested at creation.
+ * If this value is larger than the interval specified at creation of the search object, more search results are available.
+ * To fetch these, create a new search object with a new interval.
+ *
+ * @param[in] search Search object
+ *
+ * @return The total number of playlists matching the original query
+ */
+SP_LIBEXPORT(int) sp_search_total_playlists(sp_search *search);
+
+/**
* Increase the reference count of a search result
*
* @param[in] search The search result object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_search_add_ref(sp_search *search);
+SP_LIBEXPORT(sp_error) sp_search_add_ref(sp_search *search);
/**
* Decrease the reference count of a search result
*
* @param[in] search The search result object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_search_release(sp_search *search);
+SP_LIBEXPORT(sp_error) sp_search_release(sp_search *search);
/** @} */
@@ -2667,7 +2894,7 @@ SP_LIBEXPORT(bool) sp_playlist_is_loaded(sp_playlist *playlist);
* @sa sp_playlist_remove_callbacks
*
*/
-SP_LIBEXPORT(void) sp_playlist_add_callbacks(sp_playlist *playlist, sp_playlist_callbacks *callbacks, void *userdata);
+SP_LIBEXPORT(sp_error) sp_playlist_add_callbacks(sp_playlist *playlist, sp_playlist_callbacks *callbacks, void *userdata);
/**
* Unregister interest in the given playlist
@@ -2682,9 +2909,11 @@ SP_LIBEXPORT(void) sp_playlist_add_callbacks(sp_playlist *playlist, sp_playlist_
* @param[in] callbacks Callbacks, see #sp_playlist_callbacks
* @param[in] userdata Userdata to be passed to callbacks
* @sa sp_playlist_add_callbacks
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*
*/
-SP_LIBEXPORT(void) sp_playlist_remove_callbacks(sp_playlist *playlist, sp_playlist_callbacks *callbacks, void *userdata);
+SP_LIBEXPORT(sp_error) sp_playlist_remove_callbacks(sp_playlist *playlist, sp_playlist_callbacks *callbacks, void *userdata);
/**
* Return number of tracks in the given playlist
@@ -2808,9 +3037,10 @@ SP_LIBEXPORT(bool) sp_playlist_is_collaborative(sp_playlist *playlist);
*
* @param[in] playlist Playlist object
* @param[in] collaborative True or false
- *
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlist_set_collaborative(sp_playlist *playlist, bool collaborative);
+SP_LIBEXPORT(sp_error) sp_playlist_set_collaborative(sp_playlist *playlist, bool collaborative);
/**
* Set autolinking state for a playlist.
@@ -2820,9 +3050,10 @@ SP_LIBEXPORT(void) sp_playlist_set_collaborative(sp_playlist *playlist, bool col
*
* @param[in] playlist Playlist object
* @param[in] link True or false
- *
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlist_set_autolink_tracks(sp_playlist *playlist, bool link);
+SP_LIBEXPORT(sp_error) sp_playlist_set_autolink_tracks(sp_playlist *playlist, bool link);
/**
@@ -2937,8 +3168,10 @@ SP_LIBEXPORT(sp_subscribers *) sp_playlist_subscribers(sp_playlist *playlist);
* Free object returned from sp_playlist_subscribers()
*
* @param[in] subscribers Subscribers object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlist_subscribers_free(sp_subscribers *subscribers);
+SP_LIBEXPORT(sp_error) sp_playlist_subscribers_free(sp_subscribers *subscribers);
/**
* Ask library to update the subscription count for a playlist
@@ -2952,8 +3185,10 @@ SP_LIBEXPORT(void) sp_playlist_subscribers_free(sp_subscribers *subscribers);
*
* @param[in] session Session object
* @param[in] playlist Playlist object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlist_update_subscribers(sp_session *session, sp_playlist *playlist);
+SP_LIBEXPORT(sp_error) sp_playlist_update_subscribers(sp_session *session, sp_playlist *playlist);
/**
* Return whether a playlist is loaded in RAM (as opposed to only
@@ -2993,8 +3228,10 @@ SP_LIBEXPORT(bool) sp_playlist_is_in_ram(sp_session *session, sp_playlist *playl
* @param[in] session Session object
* @param[in] playlist Playlist object
* @param[in] in_ram Controls whether or not to keep the list in RAM
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlist_set_in_ram(sp_session *session, sp_playlist *playlist, bool in_ram);
+SP_LIBEXPORT(sp_error) sp_playlist_set_in_ram(sp_session *session, sp_playlist *playlist, bool in_ram);
/**
* Load an already existing playlist without adding it to a playlistcontainer.
@@ -3014,8 +3251,10 @@ SP_LIBEXPORT(sp_playlist *) sp_playlist_create(sp_session *session, sp_link *lin
* @param[in] session Session object
* @param[in] playlist Playlist object
* @param[in] offline True iff playlist should be offline, false otherwise
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlist_set_offline_mode(sp_session *session, sp_playlist *playlist, bool offline);
+SP_LIBEXPORT(sp_error) sp_playlist_set_offline_mode(sp_session *session, sp_playlist *playlist, bool offline);
/**
* Get offline status for a playlist
@@ -3048,15 +3287,19 @@ SP_LIBEXPORT(int) sp_playlist_get_offline_download_completed(sp_session *session
* Increase the reference count of a playlist
*
* @param[in] playlist The playlist object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlist_add_ref(sp_playlist *playlist);
+SP_LIBEXPORT(sp_error) sp_playlist_add_ref(sp_playlist *playlist);
/**
* Decrease the reference count of a playlist
*
* @param[in] playlist The playlist object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlist_release(sp_playlist *playlist);
+SP_LIBEXPORT(sp_error) sp_playlist_release(sp_playlist *playlist);
/**
@@ -3124,8 +3367,10 @@ typedef struct sp_playlistcontainer_callbacks {
*
* @sa sp_session_playlistcontainer()
* @sa sp_playlistcontainer_remove_callbacks
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlistcontainer_add_callbacks(sp_playlistcontainer *pc, sp_playlistcontainer_callbacks *callbacks, void *userdata);
+SP_LIBEXPORT(sp_error) sp_playlistcontainer_add_callbacks(sp_playlistcontainer *pc, sp_playlistcontainer_callbacks *callbacks, void *userdata);
/**
@@ -3137,8 +3382,10 @@ SP_LIBEXPORT(void) sp_playlistcontainer_add_callbacks(sp_playlistcontainer *pc,
*
* @sa sp_session_playlistcontainer()
* @sa sp_playlistcontainer_add_callbacks
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlistcontainer_remove_callbacks(sp_playlistcontainer *pc, sp_playlistcontainer_callbacks *callbacks, void *userdata);
+SP_LIBEXPORT(sp_error) sp_playlistcontainer_remove_callbacks(sp_playlistcontainer *pc, sp_playlistcontainer_callbacks *callbacks, void *userdata);
/**
* Return the number of playlists in the given playlist container
@@ -3301,15 +3548,19 @@ SP_LIBEXPORT(sp_user *) sp_playlistcontainer_owner(sp_playlistcontainer *pc);
* Increase reference count on playlistconatiner object
*
* @param[in] pc Playlist container.
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlistcontainer_add_ref(sp_playlistcontainer *pc);
+SP_LIBEXPORT(sp_error) sp_playlistcontainer_add_ref(sp_playlistcontainer *pc);
/**
* Release reference count on playlistconatiner object
*
* @param[in] pc Playlist container.
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_playlistcontainer_release(sp_playlistcontainer *pc);
+SP_LIBEXPORT(sp_error) sp_playlistcontainer_release(sp_playlistcontainer *pc);
/**
* Get the number of new tracks in a playlist since the corresponding
@@ -3392,15 +3643,19 @@ SP_LIBEXPORT(bool) sp_user_is_loaded(sp_user *user);
* Increase the reference count of an user
*
* @param[in] user The user object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_user_add_ref(sp_user *user);
+SP_LIBEXPORT(sp_error) sp_user_add_ref(sp_user *user);
/**
* Decrease the reference count of an user
*
* @param[in] user The user object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_user_release(sp_user *user);
+SP_LIBEXPORT(sp_error) sp_user_release(sp_user *user);
/** @} */
@@ -3498,15 +3753,19 @@ SP_LIBEXPORT(sp_error) sp_toplistbrowse_error(sp_toplistbrowse *tlb);
* Increase the reference count of an toplist browse result
*
* @param[in] tlb The toplist browse result object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_toplistbrowse_add_ref(sp_toplistbrowse *tlb);
+SP_LIBEXPORT(sp_error) sp_toplistbrowse_add_ref(sp_toplistbrowse *tlb);
/**
* Decrease the reference count of an toplist browse result
*
* @param[in] tlb The toplist browse result object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_toplistbrowse_release(sp_toplistbrowse *tlb);
+SP_LIBEXPORT(sp_error) sp_toplistbrowse_release(sp_toplistbrowse *tlb);
/**
* Given an toplist browse object, return number of artists
@@ -3635,15 +3894,19 @@ SP_LIBEXPORT(sp_error) sp_inbox_error(sp_inbox *inbox);
* Increase the reference count of a inbox result
*
* @param[in] inbox The inbox result object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_inbox_add_ref(sp_inbox *inbox);
+SP_LIBEXPORT(sp_error) sp_inbox_add_ref(sp_inbox *inbox);
/**
* Decrease the reference count of a inbox result
*
* @param[in] inbox The inbox result object
+ * @return One of the following errors, from ::sp_error
+ * SP_ERROR_OK
*/
-SP_LIBEXPORT(void) sp_inbox_release(sp_inbox *inbox);
+SP_LIBEXPORT(sp_error) sp_inbox_release(sp_inbox *inbox);
/** @} */
View
140 ext/spotify/apifunctions.h
@@ -2,34 +2,41 @@
#ifdef CONFIG_LIBSPOTIFY_LOAD_RUNTIME
static const char*(*f_sp_error_message)(sp_error error);
static sp_error(*f_sp_session_create)(const sp_session_config *config, sp_session **sess);
-static void(*f_sp_session_release)(sp_session *sess);
-static void(*f_sp_session_login)(sp_session *session, const char *username, const char *password, bool remember_me, const char *blob);
+static sp_error(*f_sp_session_release)(sp_session *sess);
+static sp_error(*f_sp_session_login)(sp_session *session, const char *username, const char *password, bool remember_me, const char *blob);
static sp_error(*f_sp_session_relogin)(sp_session *session);
static int(*f_sp_session_remembered_user)(sp_session *session, char *buffer, size_t buffer_size);
-static void(*f_sp_session_forget_me)(sp_session *session);
+static const char *(*f_sp_session_user_name)(sp_session *session);
+static sp_error(*f_sp_session_forget_me)(sp_session *session);
static sp_user *(*f_sp_session_user)(sp_session *session);
-static void(*f_sp_session_logout)(sp_session *session);
-static void(*f_sp_session_flush_caches)(sp_session *session);
+static sp_error(*f_sp_session_logout)(sp_session *session);
+static sp_error(*f_sp_session_flush_caches)(sp_session *session);
static sp_connectionstate(*f_sp_session_connectionstate)(sp_session *session);
static void *(*f_sp_session_userdata)(sp_session *session);
-static void(*f_sp_session_set_cache_size)(sp_session *session, size_t size);
-static void(*f_sp_session_process_events)(sp_session *session, int *next_timeout);
+static sp_error(*f_sp_session_set_cache_size)(sp_session *session, size_t size);
+static sp_error(*f_sp_session_process_events)(sp_session *session, int *next_timeout);
static sp_error(*f_sp_session_player_load)(sp_session *session, sp_track *track);
-static void(*f_sp_session_player_seek)(sp_session *session, int offset);
-static void(*f_sp_session_player_play)(sp_session *session, bool play);
-static void(*f_sp_session_player_unload)(sp_session *session);
+static sp_error(*f_sp_session_player_seek)(sp_session *session, int offset);
+static sp_error(*f_sp_session_player_play)(sp_session *session, bool play);
+static sp_error(*f_sp_session_player_unload)(sp_session *session);
static sp_error(*f_sp_session_player_prefetch)(sp_session *session, sp_track *track);
static sp_playlistcontainer *(*f_sp_session_playlistcontainer)(sp_session *session);
static sp_playlist *(*f_sp_session_inbox_create)(sp_session *session);
static sp_playlist *(*f_sp_session_starred_create)(sp_session *session);
static sp_playlist *(*f_sp_session_starred_for_user_create)(sp_session *session, const char *canonical_username);
static sp_playlistcontainer *(*f_sp_session_publishedcontainer_for_user_create)(sp_session *session, const char *canonical_username);
-static void(*f_sp_session_preferred_bitrate)(sp_session *session, sp_bitrate bitrate);
-static void(*f_sp_session_preferred_offline_bitrate)(sp_session *session, sp_bitrate bitrate, bool allow_resync);
+static sp_error(*f_sp_session_preferred_bitrate)(sp_session *session, sp_bitrate bitrate);
+static sp_error(*f_sp_session_preferred_offline_bitrate)(sp_session *session, sp_bitrate bitrate, bool allow_resync);
static bool(*f_sp_session_get_volume_normalization)(sp_session *session);
-static void(*f_sp_session_set_volume_normalization)(sp_session *session, bool on);
-static void(*f_sp_session_set_connection_type)(sp_session *session, sp_connection_type type);
-static void(*f_sp_session_set_connection_rules)(sp_session *session, sp_connection_rules rules);
+static sp_error(*f_sp_session_set_volume_normalization)(sp_session *session, bool on);
+static sp_error(*f_sp_session_set_private_session)(sp_session *session, bool enabled);
+static bool(*f_sp_session_is_private_session)(sp_session *session);
+static sp_error(*f_sp_session_set_scrobbling)(sp_session *session, sp_social_provider provider, sp_scrobbling_state state);
+static sp_error(*f_sp_session_is_scrobbling)(sp_session *session, sp_social_provider provider, sp_scrobbling_state* state);
+ SP_LIBEXPORT(sp_error) sp_session_is_scrobbling_possible(sp_session *session, sp_social_provider provider, bool* out);
+static sp_error(*f_sp_session_set_social_credentials)(sp_session *session, sp_social_provider provider, const char* username, const char* password);
+static sp_error(*f_sp_session_set_connection_type)(sp_session *session, sp_connection_type type);
+static sp_error(*f_sp_session_set_connection_rules)(sp_session *session, sp_connection_rules rules);
static int(*f_sp_offline_tracks_to_sync)(sp_session *session);
static int(*f_sp_offline_num_playlists)(sp_session *session);
static bool(*f_sp_offline_sync_get_status)(sp_session *session, sp_offline_sync_status *status);
@@ -38,9 +45,9 @@ static int(*f_sp_session_user_country)(sp_session *session);
static sp_link *(*f_sp_link_create_from_string)(const char *link);
static sp_link *(*f_sp_link_create_from_track)(sp_track *track, int offset);
static sp_link *(*f_sp_link_create_from_album)(sp_album *album);
-static sp_link *(*f_sp_link_create_from_album_cover)(sp_album *album);
+static sp_link *(*f_sp_link_create_from_album_cover)(sp_album *album, sp_image_size size);
static sp_link *(*f_sp_link_create_from_artist)(sp_artist *artist);
-static sp_link *(*f_sp_link_create_from_artist_portrait)(sp_artist *artist);
+static sp_link *(*f_sp_link_create_from_artist_portrait)(sp_artist *artist, sp_image_size size);
static sp_link *(*f_sp_link_create_from_artistbrowse_portrait)(sp_artistbrowse *arb, int index);
static sp_link *(*f_sp_link_create_from_search)(sp_search *search);
static sp_link *(*f_sp_link_create_from_playlist)(sp_playlist *playlist);
@@ -53,8 +60,8 @@ static sp_track *(*f_sp_link_as_track_and_offset)(sp_link *link, int *offset);
static sp_album *(*f_sp_link_as_album)(sp_link *link);
static sp_artist *(*f_sp_link_as_artist)(sp_link *link);
static sp_user *(*f_sp_link_as_user)(sp_link *link);
-static void(*f_sp_link_add_ref)(sp_link *link);
-static void(*f_sp_link_release)(sp_link *link);
+static sp_error(*f_sp_link_add_ref)(sp_link *link);
+static sp_error(*f_sp_link_release)(sp_link *link);
static bool(*f_sp_track_is_loaded)(sp_track *track);
static sp_error(*f_sp_track_error)(sp_track *track);
static sp_track_offline_status(*f_sp_track_offline_get_status)(sp_track *track);
@@ -64,7 +71,7 @@ static bool(*f_sp_track_is_autolinked)(sp_session *session, sp_track *track);
static sp_track *(*f_sp_track_get_playable)(sp_session *session, sp_track *track);
static bool(*f_sp_track_is_placeholder)(sp_track *track);
static bool(*f_sp_track_is_starred)(sp_session *session, sp_track *track);
-static void(*f_sp_track_set_starred)(sp_session *session, sp_track *const*tracks, int num_tracks, bool star);
+static sp_error(*f_sp_track_set_starred)(sp_session *session, sp_track *const*tracks, int num_tracks, bool star);
static int(*f_sp_track_num_artists)(sp_track *track);
static sp_artist *(*f_sp_track_artist)(sp_track *track, int index);
static sp_album *(*f_sp_track_album)(sp_track *track);
@@ -74,22 +81,22 @@ static int(*f_sp_track_popularity)(sp_track *track);
static int(*f_sp_track_disc)(sp_track *track);
static int(*f_sp_track_index)(sp_track *track);
static sp_track *(*f_sp_localtrack_create)(const char *artist, const char *title, const char *album, int length);
-static void(*f_sp_track_add_ref)(sp_track *track);
-static void(*f_sp_track_release)(sp_track *track);
+static sp_error(*f_sp_track_add_ref)(sp_track *track);
+static sp_error(*f_sp_track_release)(sp_track *track);
static bool(*f_sp_album_is_loaded)(sp_album *album);
static bool(*f_sp_album_is_available)(sp_album *album);
static sp_artist *(*f_sp_album_artist)(sp_album *album);
-static const byte *(*f_sp_album_cover)(sp_album *album);
+static const byte *(*f_sp_album_cover)(sp_album *album, sp_image_size size);
static const char *(*f_sp_album_name)(sp_album *album);
static int(*f_sp_album_year)(sp_album *album);
static sp_albumtype(*f_sp_album_type)(sp_album *album);
-static void(*f_sp_album_add_ref)(sp_album *album);
-static void(*f_sp_album_release)(sp_album *album);
+static sp_error(*f_sp_album_add_ref)(sp_album *album);
+static sp_error(*f_sp_album_release)(sp_album *album);
static const char *(*f_sp_artist_name)(sp_artist *artist);
static bool(*f_sp_artist_is_loaded)(sp_artist *artist);
-static const byte *(*f_sp_artist_portrait)(sp_artist *artist);
-static void(*f_sp_artist_add_ref)(sp_artist *artist);
-static void(*f_sp_artist_release)(sp_artist *artist);
+static const byte *(*f_sp_artist_portrait)(sp_artist *artist, sp_image_size size);
+static sp_error(*f_sp_artist_add_ref)(sp_artist *artist);
+static sp_error(*f_sp_artist_release)(sp_artist *artist);
static sp_albumbrowse *(*f_sp_albumbrowse_create)(sp_session *session, sp_album *album, albumbrowse_complete_cb *callback, void *userdata);
static bool(*f_sp_albumbrowse_is_loaded)(sp_albumbrowse *alb);
static sp_error(*f_sp_albumbrowse_error)(sp_albumbrowse *alb);
@@ -101,8 +108,8 @@ static int(*f_sp_albumbrowse_num_tracks)(sp_albumbrowse *alb);
static sp_track *(*f_sp_albumbrowse_track)(sp_albumbrowse *alb, int index);
static const char *(*f_sp_albumbrowse_review)(sp_albumbrowse *alb);
static int(*f_sp_albumbrowse_backend_request_duration)(sp_albumbrowse *alb);
-static void(*f_sp_albumbrowse_add_ref)(sp_albumbrowse *alb);
-static void(*f_sp_albumbrowse_release)(sp_albumbrowse *alb);
+static sp_error(*f_sp_albumbrowse_add_ref)(sp_albumbrowse *alb);
+static sp_error(*f_sp_albumbrowse_release)(sp_albumbrowse *alb);
static sp_artistbrowse *(*f_sp_artistbrowse_create)(sp_session *session, sp_artist *artist, sp_artistbrowse_type type, artistbrowse_complete_cb *callback, void *userdata);
static bool(*f_sp_artistbrowse_is_loaded)(sp_artistbrowse *arb);
static sp_error(*f_sp_artistbrowse_error)(sp_artistbrowse *arb);
@@ -119,19 +126,19 @@ static int(*f_sp_artistbrowse_num_similar_artists)(sp_artistbrowse *arb);
static sp_artist *(*f_sp_artistbrowse_similar_artist)(sp_artistbrowse *arb, int index);
static const char *(*f_sp_artistbrowse_biography)(sp_artistbrowse *arb);
static int(*f_sp_artistbrowse_backend_request_duration)(sp_artistbrowse *arb);
-static void(*f_sp_artistbrowse_add_ref)(sp_artistbrowse *arb);
-static void(*f_sp_artistbrowse_release)(sp_artistbrowse *arb);
+static sp_error(*f_sp_artistbrowse_add_ref)(sp_artistbrowse *arb);
+static sp_error(*f_sp_artistbrowse_release)(sp_artistbrowse *arb);
static sp_image *(*f_sp_image_create)(sp_session *session, const byte image_id[20]);
static sp_image *(*f_sp_image_create_from_link)(sp_session *session, sp_link *l);
-static void(*f_sp_image_add_load_callback)(sp_image *image, image_loaded_cb *callback, void *userdata);
-static void(*f_sp_image_remove_load_callback)(sp_image *image, image_loaded_cb *callback, void *userdata);
+static sp_error(*f_sp_image_add_load_callback)(sp_image *image, image_loaded_cb *callback, void *userdata);
+static sp_error(*f_sp_image_remove_load_callback)(sp_image *image, image_loaded_cb *callback, void *userdata);
static bool(*f_sp_image_is_loaded)(sp_image *image);
static sp_error(*f_sp_image_error)(sp_image *image);
static sp_imageformat(*f_sp_image_format)(sp_image *image);
static const void *(*f_sp_image_data)(sp_image *image, size_t *data_size);
static const byte *(*f_sp_image_image_id)(sp_image *image);
-static void(*f_sp_image_add_ref)(sp_image *image);
-static void(*f_sp_image_release)(sp_image *image);
+static sp_error(*f_sp_image_add_ref)(sp_image *image);
+static sp_error(*f_sp_image_release)(sp_image *image);
static sp_search *(*f_sp_search_create)(sp_session *session, const char *query, int track_offset, int track_count, int album_offset, int album_count, int artist_offset, int artist_count, int playlist_offset, int playlist_count, sp_search_type search_type, search_complete_cb *callback, void *userdata);
static bool(*f_sp_search_is_loaded)(sp_search *search);
static sp_error(*f_sp_search_error)(sp_search *search);
@@ -150,11 +157,12 @@ static const char *(*f_sp_search_did_you_mean)(sp_search *search);
static int(*f_sp_search_total_tracks)(sp_search *search);
static int(*f_sp_search_total_albums)(sp_search *search);
static int(*f_sp_search_total_artists)(sp_search *search);
-static void(*f_sp_search_add_ref)(sp_search *search);
-static void(*f_sp_search_release)(sp_search *search);
+static int(*f_sp_search_total_playlists)(sp_search *search);
+static sp_error(*f_sp_search_add_ref)(sp_search *search);
+static sp_error(*f_sp_search_release)(sp_search *search);
static bool(*f_sp_playlist_is_loaded)(sp_playlist *playlist);
-static void(*f_sp_playlist_add_callbacks)(sp_playlist *playlist, sp_playlist_callbacks *callbacks, void *userdata);
-static void(*f_sp_playlist_remove_callbacks)(sp_playlist *playlist, sp_playlist_callbacks *callbacks, void *userdata);
+static sp_error(*f_sp_playlist_add_callbacks)(sp_playlist *playlist, sp_playlist_callbacks *callbacks, void *userdata);
+static sp_error(*f_sp_playlist_remove_callbacks)(sp_playlist *playlist, sp_playlist_callbacks *callbacks, void *userdata);
static int(*f_sp_playlist_num_tracks)(sp_playlist *playlist);
static sp_track *(*f_sp_playlist_track)(sp_playlist *playlist, int index);
static int(*f_sp_playlist_track_create_time)(sp_playlist *playlist, int index);
@@ -166,8 +174,8 @@ static const char *(*f_sp_playlist_name)(sp_playlist *playlist);
static sp_error(*f_sp_playlist_rename)(sp_playlist *playlist, const char *new_name);
static sp_user *(*f_sp_playlist_owner)(sp_playlist *playlist);
static bool(*f_sp_playlist_is_collaborative)(sp_playlist *playlist);
-static void(*f_sp_playlist_set_collaborative)(sp_playlist *playlist, bool collaborative);
-static void(*f_sp_playlist_set_autolink_tracks)(sp_playlist *playlist, bool link);
+static sp_error(*f_sp_playlist_set_collaborative)(sp_playlist *playlist, bool collaborative);
+static sp_error(*f_sp_playlist_set_autolink_tracks)(sp_playlist *playlist, bool link);
static const char *(*f_sp_playlist_get_description)(sp_playlist *playlist);
static bool(*f_sp_playlist_get_image)(sp_playlist *playlist, byte image[20]);
static bool(*f_sp_playlist_has_pending_changes)(sp_playlist *playlist);
@@ -176,18 +184,18 @@ static sp_error(*f_sp_playlist_remove_tracks)(sp_playlist *playlist, const int *
static sp_error(*f_sp_playlist_reorder_tracks)(sp_playlist *playlist, const int *tracks, int num_tracks, int new_position);
static unsigned int(*f_sp_playlist_num_subscribers)(sp_playlist *playlist);
static sp_subscribers *(*f_sp_playlist_subscribers)(sp_playlist *playlist);
-static void(*f_sp_playlist_subscribers_free)(sp_subscribers *subscribers);
-static void(*f_sp_playlist_update_subscribers)(sp_session *session, sp_playlist *playlist);
+static sp_error(*f_sp_playlist_subscribers_free)(sp_subscribers *subscribers);
+static sp_error(*f_sp_playlist_update_subscribers)(sp_session *session, sp_playlist *playlist);
static bool(*f_sp_playlist_is_in_ram)(sp_session *session, sp_playlist *playlist);
-static void(*f_sp_playlist_set_in_ram)(sp_session *session, sp_playlist *playlist, bool in_ram);
+static sp_error(*f_sp_playlist_set_in_ram)(sp_session *session, sp_playlist *playlist, bool in_ram);
static sp_playlist *(*f_sp_playlist_create)(sp_session *session, sp_link *link);
-static void(*f_sp_playlist_set_offline_mode)(sp_session *session, sp_playlist *playlist, bool offline);
+static sp_error(*f_sp_playlist_set_offline_mode)(sp_session *session, sp_playlist *playlist, bool offline);
static sp_playlist_offline_status(*f_sp_playlist_get_offline_status)(sp_session *session, sp_playlist *playlist);
static int(*f_sp_playlist_get_offline_download_completed)(sp_session *session, sp_playlist *playlist);
-static void(*f_sp_playlist_add_ref)(sp_playlist *playlist);
-static void(*f_sp_playlist_release)(sp_playlist *playlist);
-static void(*f_sp_playlistcontainer_add_callbacks)(sp_playlistcontainer *pc, sp_playlistcontainer_callbacks *callbacks, void *userdata);
-static void(*f_sp_playlistcontainer_remove_callbacks)(sp_playlistcontainer *pc, sp_playlistcontainer_callbacks *callbacks, void *userdata);
+static sp_error(*f_sp_playlist_add_ref)(sp_playlist *playlist);
+static sp_error(*f_sp_playlist_release)(sp_playlist *playlist);
+static sp_error(*f_sp_playlistcontainer_add_callbacks)(sp_playlistcontainer *pc, sp_playlistcontainer_callbacks *callbacks, void *userdata);
+static sp_error(*f_sp_playlistcontainer_remove_callbacks)(sp_playlistcontainer *pc, sp_playlistcontainer_callbacks *callbacks, void *userdata);
static int(*f_sp_playlistcontainer_num_playlists)(sp_playlistcontainer *pc);
static bool(*f_sp_playlistcontainer_is_loaded)(sp_playlistcontainer *pc);
static sp_playlist *(*f_sp_playlistcontainer_playlist)(sp_playlistcontainer *pc, int index);
@@ -200,20 +208,20 @@ static sp_error(*f_sp_playlistcontainer_remove_playlist)(sp_playlistcontainer *p
static sp_error(*f_sp_playlistcontainer_move_playlist)(sp_playlistcontainer *pc, int index, int new_position, bool dry_run);
static sp_error(*f_sp_playlistcontainer_add_folder)(sp_playlistcontainer *pc, int index, const char *name);
static sp_user *(*f_sp_playlistcontainer_owner)(sp_playlistcontainer *pc);
-static void(*f_sp_playlistcontainer_add_ref)(sp_playlistcontainer *pc);
-static void(*f_sp_playlistcontainer_release)(sp_playlistcontainer *pc);
+static sp_error(*f_sp_playlistcontainer_add_ref)(sp_playlistcontainer *pc);
+static sp_error(*f_sp_playlistcontainer_release)(sp_playlistcontainer *pc);
static int(*f_sp_playlistcontainer_get_unseen_tracks)(sp_playlistcontainer *pc, sp_playlist *playlist, sp_track **tracks, int num_tracks);
static int(*f_sp_playlistcontainer_clear_unseen_tracks)(sp_playlistcontainer *pc, sp_playlist *playlist);
static const char *(*f_sp_user_canonical_name)(sp_user *user);
static const char *(*f_sp_user_display_name)(sp_user *user);
static bool(*f_sp_user_is_loaded)(sp_user *user);
-static void(*f_sp_user_add_ref)(sp_user *user);
-static void(*f_sp_user_release)(sp_user *user);
+static sp_error(*f_sp_user_add_ref)(sp_user *user);
+static sp_error(*f_sp_user_release)(sp_user *user);
static sp_toplistbrowse *(*f_sp_toplistbrowse_create)(sp_session *session, sp_toplisttype type, sp_toplistregion region, const char *username, toplistbrowse_complete_cb *callback, void *userdata);
static bool(*f_sp_toplistbrowse_is_loaded)(sp_toplistbrowse *tlb);
static sp_error(*f_sp_toplistbrowse_error)(sp_toplistbrowse *tlb);
-static void(*f_sp_toplistbrowse_add_ref)(sp_toplistbrowse *tlb);
-static void(*f_sp_toplistbrowse_release)(sp_toplistbrowse *tlb);
+static sp_error(*f_sp_toplistbrowse_add_ref)(sp_toplistbrowse *tlb);
+static sp_error(*f_sp_toplistbrowse_release)(sp_toplistbrowse *tlb);
static int(*f_sp_toplistbrowse_num_artists)(sp_toplistbrowse *tlb);
static sp_artist *(*f_sp_toplistbrowse_artist)(sp_toplistbrowse *tlb, int index);
static int(*f_sp_toplistbrowse_num_albums)(sp_toplistbrowse *tlb);
@@ -223,8 +231,8 @@ static sp_track *(*f_sp_toplistbrowse_track)(sp_toplistbrowse *tlb, int index);
static int(*f_sp_toplistbrowse_backend_request_duration)(sp_toplistbrowse *tlb);
static sp_inbox *(*f_sp_inbox_post_tracks)(sp_session *session, const char *user, sp_track * const *tracks, int num_tracks, const char *message, inboxpost_complete_cb *callback, void *userdata);
static sp_error(*f_sp_inbox_error)(sp_inbox *inbox);
-static void(*f_sp_inbox_add_ref)(sp_inbox *inbox);
-static void(*f_sp_inbox_release)(sp_inbox *inbox);
+static sp_error(*f_sp_inbox_add_ref)(sp_inbox *inbox);
+static sp_error(*f_sp_inbox_release)(sp_inbox *inbox);
static const char *(*f_sp_build_id)(void);
static const char *resolvesym(void *handle) {
if((f_sp_error_message=dlsym(handle,"sp_error_message"))==NULL) return "sp_error_message";
@@ -233,6 +241,7 @@ if((f_sp_session_release=dlsym(handle,"sp_session_release"))==NULL) return "sp_s
if((f_sp_session_login=dlsym(handle,"sp_session_login"))==NULL) return "sp_session_login";
if((f_sp_session_relogin=dlsym(handle,"sp_session_relogin"))==NULL) return "sp_session_relogin";
if((f_sp_session_remembered_user=dlsym(handle,"sp_session_remembered_user"))==NULL) return "sp_session_remembered_user";
+if((f_sp_session_user_name=dlsym(handle,"sp_session_user_name"))==NULL) return "sp_session_user_name";
if((f_sp_session_forget_me=dlsym(handle,"sp_session_forget_me"))==NULL) return "sp_session_forget_me";
if((f_sp_session_user=dlsym(handle,"sp_session_user"))==NULL) return "sp_session_user";
if((f_sp_session_logout=dlsym(handle,"sp_session_logout"))==NULL) return "sp_session_logout";
@@ -255,6 +264,12 @@ if((f_sp_session_preferred_bitrate=dlsym(handle,"sp_session_preferred_bitrate"))
if((f_sp_session_preferred_offline_bitrate=dlsym(handle,"sp_session_preferred_offline_bitrate"))==NULL) return "sp_session_preferred_offline_bitrate";
if((f_sp_session_get_volume_normalization=dlsym(handle,"sp_session_get_volume_normalization"))==NULL) return "sp_session_get_volume_normalization";
if((f_sp_session_set_volume_normalization=dlsym(handle,"sp_session_set_volume_normalization"))==NULL) return "sp_session_set_volume_normalization";
+if((f_sp_session_set_private_session=dlsym(handle,"sp_session_set_private_session"))==NULL) return "sp_session_set_private_session";
+if((f_sp_session_is_private_session=dlsym(handle,"sp_session_is_private_session"))==NULL) return "sp_session_is_private_session";
+if((f_sp_session_set_scrobbling=dlsym(handle,"sp_session_set_scrobbling"))==NULL) return "sp_session_set_scrobbling";
+if((f_sp_session_is_scrobbling=dlsym(handle,"sp_session_is_scrobbling"))==NULL) return "sp_session_is_scrobbling";
+ SP_LIBEXPORT(sp_error) sp_session_is_scrobbling_possible(sp_session *session, sp_social_provider provider, bool* out);
+if((f_sp_session_set_social_credentials=dlsym(handle,"sp_session_set_social_credentials"))==NULL) return "sp_session_set_social_credentials";
if((f_sp_session_set_connection_type=dlsym(handle,"sp_session_set_connection_type"))==NULL) return "sp_session_set_connection_type";
if((f_sp_session_set_connection_rules=dlsym(handle,"sp_session_set_connection_rules"))==NULL) return "sp_session_set_connection_rules";
if((f_sp_offline_tracks_to_sync=dlsym(handle,"sp_offline_tracks_to_sync"))==NULL) return "sp_offline_tracks_to_sync";
@@ -377,6 +392,7 @@ if((f_sp_search_did_you_mean=dlsym(handle,"sp_search_did_you_mean"))==NULL) retu
if((f_sp_search_total_tracks=dlsym(handle,"sp_search_total_tracks"))==NULL) return "sp_search_total_tracks";
if((f_sp_search_total_albums=dlsym(handle,"sp_search_total_albums"))==NULL) return "sp_search_total_albums";
if((f_sp_search_total_artists=dlsym(handle,"sp_search_total_artists"))==NULL) return "sp_search_total_artists";
+if((f_sp_search_total_playlists=dlsym(handle,"sp_search_total_playlists"))==NULL) return "sp_search_total_playlists";
if((f_sp_search_add_ref=dlsym(handle,"sp_search_add_ref"))==NULL) return "sp_search_add_ref";
if((f_sp_search_release=dlsym(handle,"sp_search_release"))==NULL) return "sp_search_release";
if((f_sp_playlist_is_loaded=dlsym(handle,"sp_playlist_is_loaded"))==NULL) return "sp_playlist_is_loaded";
@@ -461,6 +477,7 @@ return NULL;}
#define f_sp_session_login sp_session_login
#define f_sp_session_relogin sp_session_relogin
#define f_sp_session_remembered_user sp_session_remembered_user
+#define f_sp_session_user_name sp_session_user_name
#define f_sp_session_forget_me sp_session_forget_me
#define f_sp_session_user sp_session_user
#define f_sp_session_logout sp_session_logout
@@ -483,6 +500,12 @@ return NULL;}
#define f_sp_session_preferred_offline_bitrate sp_session_preferred_offline_bitrate
#define f_sp_session_get_volume_normalization sp_session_get_volume_normalization
#define f_sp_session_set_volume_normalization sp_session_set_volume_normalization
+#define f_sp_session_set_private_session sp_session_set_private_session
+#define f_sp_session_is_private_session sp_session_is_private_session
+#define f_sp_session_set_scrobbling sp_session_set_scrobbling
+#define f_sp_session_is_scrobbling sp_session_is_scrobbling
+ SP_LIBEXPORT(sp_error) sp_session_is_scrobbling_possible(sp_session *session, sp_social_provider provider, bool* out);
+#define f_sp_session_set_social_credentials sp_session_set_social_credentials
#define f_sp_session_set_connection_type sp_session_set_connection_type
#define f_sp_session_set_connection_rules sp_session_set_connection_rules
#define f_sp_offline_tracks_to_sync sp_offline_tracks_to_sync
@@ -605,6 +628,7 @@ return NULL;}
#define f_sp_search_total_tracks sp_search_total_tracks
#define f_sp_search_total_albums sp_search_total_albums
#define f_sp_search_total_artists sp_search_total_artists
+#define f_sp_search_total_playlists sp_search_total_playlists
#define f_sp_search_add_ref sp_search_add_ref
#define f_sp_search_release sp_search_release
#define f_sp_playlist_is_loaded sp_playlist_is_loaded
View
63 src/backend/spotify/spotify.c
@@ -45,6 +45,7 @@
#include "misc/pixmap.h"
#include "settings.h"
#include "htsmsg/htsbuf.h"
+#include "htsmsg/htsmsg_json.h"
#include "metadata/metadata.h"
#include "api/lastfm.h"
@@ -912,22 +913,53 @@ spotify_play_track(spotify_uri_t *su)
}
+typedef sp_link *(link_fn_t)(sp_album *, sp_image_size);
/**
*
*/
static void
-set_image_uri(prop_t *p, sp_link *link)
+set_image_uri(prop_t *p, link_fn_t *link_fn, void *entity)
{
char url[100];
+ const int size[] = { 64, 300, 640 };
+ const sp_image_size size_enum[] =
+ { SP_IMAGE_SIZE_SMALL, SP_IMAGE_SIZE_NORMAL, SP_IMAGE_SIZE_LARGE };
- if(link == NULL)
+ htsmsg_t *m = NULL;
+ for (int i = 0; i < ARRAYSIZE(size); i++) {
+
+ htsmsg_t *img = htsmsg_create_map();
+ sp_link *link = link_fn(entity, size_enum[i]);
+ if (!link)
+ continue;
+ if (!f_sp_link_as_string(link, url, sizeof (url))) {
+ f_sp_link_release(link);
+ continue;
+ }
+ f_sp_link_release(link);
+
+ htsmsg_add_str(img, "url", url);
+ htsmsg_add_u32(img, "width", size[i]);
+ htsmsg_add_u32(img, "height", size[i]);
+ if (!m)
+ m = htsmsg_create_list();
+ htsmsg_add_msg(m, NULL, img);
+ }
+ if (!m) {
+ prop_set_void(p);
return;
+ }
- if(f_sp_link_as_string(link, url, sizeof(url)))
- prop_set_string(p, url);
- f_sp_link_release(link);
-}
+ htsbuf_queue_t hq;
+ htsbuf_queue_init(&hq, 0);
+ htsbuf_qprintf(&hq, "imageset:");
+ htsmsg_json_serialize(m, &hq, 0);
+ rstr_t *rstr = htsbuf_to_rstr(&hq);
+ htsbuf_queue_flush(&hq);
+ prop_set_rstring(p, rstr);
+ htsmsg_destroy(m);
+}
/**
*
@@ -1028,7 +1060,7 @@ spotify_metadata_update_track(spotify_metadata_t *m)
if(album != NULL) {
spotify_make_link(f_sp_link_create_from_album(album), url, sizeof(url));
prop_set_link(m->m_album, f_sp_album_name(album), url);
- set_image_uri(m->m_album_art, f_sp_link_create_from_album_cover(album));
+ set_image_uri(m->m_album_art, f_sp_link_create_from_album_cover, album);
prop_set_int(m->m_album_year, f_sp_album_year(album));
}
@@ -1339,8 +1371,8 @@ spotify_browse_album_callback(sp_albumbrowse *result, void *userdata)
if(y)
prop_set_int(bh->sp->sp_album_year, y);
- set_image_uri(bh->sp->sp_icon, f_sp_link_create_from_album_cover(alb));
- set_image_uri(bh->sp->sp_album_art, f_sp_link_create_from_album_cover(alb));
+ set_image_uri(bh->sp->sp_icon, f_sp_link_create_from_album_cover, alb);
+ set_image_uri(bh->sp->sp_album_art, f_sp_link_create_from_album_cover, alb);
prop_set_string(bh->sp->sp_artist_name,
f_sp_artist_name(f_sp_album_artist(alb)));
@@ -1448,7 +1480,7 @@ spotify_add_album(sp_album *album, sp_artist *artist, prop_t *parent)
f_sp_artist_name(artist), link);
set_image_uri(prop_create(metadata, "album_art"),
- f_sp_link_create_from_album_cover(album));
+ f_sp_link_create_from_album_cover, album);
if(prop_set_parent(p, parent))
prop_destroy(p);
@@ -1698,7 +1730,7 @@ try_resolve_track_item(spotify_page_t *sp)
if(album != NULL) {
spotify_make_link(f_sp_link_create_from_album(album), url, sizeof(url));
prop_set_link(sp->sp_album_name, f_sp_album_name(album), url);
- set_image_uri(sp->sp_album_art, f_sp_link_create_from_album_cover(album));
+ set_image_uri(sp->sp_album_art, f_sp_link_create_from_album_cover, album);
prop_set_int(sp->sp_album_year, f_sp_album_year(album));
}
@@ -3487,7 +3519,7 @@ ss_fill_albums(sp_search *result, spotify_search_request_t *ssr)
f_sp_artist_name(artist), link);
set_image_uri(prop_create(metadata, "icon"),
- f_sp_link_create_from_album_cover(album));
+ f_sp_link_create_from_album_cover, album);
pv = prop_vec_append(pv, p);
album_prev = album;
@@ -3530,11 +3562,8 @@ ss_fill_artists(sp_search *result, spotify_search_request_t *ssr)
metadata = prop_create(p, "metadata");
prop_set_string(prop_create(metadata, "title"), f_sp_artist_name(artist));
- sp_link *l = f_sp_link_create_from_artist_portrait(artist);
- if(l != NULL) {
- spotify_make_link(l, link, sizeof(link));
- prop_set_string(prop_create(metadata, "icon"), link);
- }
+ set_image_uri(prop_create(metadata, "icon"),
+ (link_fn_t *)f_sp_link_create_from_artist_portrait, artist);
pv = prop_vec_append(pv, p);
inc++;
View
2  src/showtime.h
@@ -38,6 +38,8 @@ extern const char *showtime_dataroot(void);
#define DISABLE_CACHE ((int *)-2)
#define NOT_MODIFIED ((void *)-1)
+#define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
+
#define ONLY_CACHED(p) ((p) != BYPASS_CACHE && (p) != NULL)
// NLS
View
2  support/configure.inc
@@ -17,7 +17,7 @@ TMPDIR=${TOPDIR}/tmp
GLW_DEFAULT_THEME="mono"
DEFAULT_LOGTARGET=""
JARGS=""
-LIBSPOTIFY_VERSION="11.1.60"
+LIBSPOTIFY_VERSION="12.1.51"
CONFIG_LIST="
libasound
Please sign in to comment.
Something went wrong with that request. Please try again.