mockspotify 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,28 +1,6 @@
1
- Makefile
2
- Makefile.in
3
- aclocal.m4
4
- autom4te.cache/
5
- config.guess
6
- config.h
7
- config.h.in
8
- config.log
9
- config.status
10
- config.sub
11
- configure
12
- depcomp
13
- install-sh
14
- libtool
15
- ltmain.sh
16
- m4/
17
- missing
18
- src/.deps/
19
- src/.libs/
20
- src/*.o
21
- src/*.la
22
- src/*.lo
23
- src/Makefile
24
- src/Makefile.in
25
- stamp-h1
26
1
  *.bundle
27
2
  pkg/
28
3
  Gemfile.lock
4
+ ext/*
5
+ !ext/libmockspotify
6
+ !ext/extconf.rb
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "ext/libmockspotify"]
2
+ path = ext/libmockspotify
3
+ url = git://github.com/Burgestrand/libmockspotify.git
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
  require 'bundler/gem_tasks'
3
3
 
4
4
  task :compile do
5
- Dir.chdir('src') do
5
+ Dir.chdir('ext') do
6
6
  sh 'ruby extconf.rb'
7
7
  sh 'make'
8
8
  end
@@ -14,3 +14,4 @@ Rake::TestTask.new do |t|
14
14
  end
15
15
 
16
16
  task :test => :compile
17
+ task :default => :test
data/ext/extconf.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'mkmf'
2
+
3
+ $CFLAGS << ' -O0 -ggdb -Wextra '
4
+
5
+ create_makefile 'libmockspotify', 'libmockspotify/src'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -97,25 +97,25 @@ typedef enum sp_error {
97
97
  SP_ERROR_BAD_API_VERSION = 1, ///< The library version targeted does not match the one you claim you support
98
98
  SP_ERROR_API_INITIALIZATION_FAILED = 2, ///< Initialization of library failed - are cache locations etc. valid?
99
99
  SP_ERROR_TRACK_NOT_PLAYABLE = 3, ///< The track specified for playing cannot be played
100
- SP_ERROR_RESOURCE_NOT_LOADED = 4, ///< One or several of the supplied resources is not yet loaded
101
100
  SP_ERROR_BAD_APPLICATION_KEY = 5, ///< The application key is invalid
102
101
  SP_ERROR_BAD_USERNAME_OR_PASSWORD = 6, ///< Login failed because of bad username and/or password
103
102
  SP_ERROR_USER_BANNED = 7, ///< The specified username is banned
104
103
  SP_ERROR_UNABLE_TO_CONTACT_SERVER = 8, ///< Cannot connect to the Spotify backend system
105
104
  SP_ERROR_CLIENT_TOO_OLD = 9, ///< Client is too old, library will need to be updated
106
- SP_ERROR_OTHER_PERMANENT = 10, ///< Some other error occured, and it is permanent (e.g. trying to relogin will not help)
105
+ SP_ERROR_OTHER_PERMANENT = 10, ///< Some other error occurred, and it is permanent (e.g. trying to relogin will not help)
107
106
  SP_ERROR_BAD_USER_AGENT = 11, ///< The user agent string is invalid or too long
108
107
  SP_ERROR_MISSING_CALLBACK = 12, ///< No valid callback registered to handle events
109
108
  SP_ERROR_INVALID_INDATA = 13, ///< Input data was either missing or invalid
110
109
  SP_ERROR_INDEX_OUT_OF_RANGE = 14, ///< Index out of range
111
110
  SP_ERROR_USER_NEEDS_PREMIUM = 15, ///< The specified user needs a premium account
112
- SP_ERROR_OTHER_TRANSIENT = 16, ///< A transient error occured.
111
+ SP_ERROR_OTHER_TRANSIENT = 16, ///< A transient error occurred.
113
112
  SP_ERROR_IS_LOADING = 17, ///< The resource is currently loading
114
113
  SP_ERROR_NO_STREAM_AVAILABLE = 18, ///< Could not find any suitable stream to play
115
114
  SP_ERROR_PERMISSION_DENIED = 19, ///< Requested operation is not allowed
116
115
  SP_ERROR_INBOX_IS_FULL = 20, ///< Target inbox is full
117
116
  SP_ERROR_NO_CACHE = 21, ///< Cache is not enabled
118
117
  SP_ERROR_NO_SUCH_USER = 22, ///< Requested user does not exist
118
+ SP_ERROR_NO_CREDENTIALS = 23, ///< No credentials are stored
119
119
  } sp_error;
120
120
 
121
121
  /**
@@ -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 8
150
+ #define SPOTIFY_API_VERSION 9
151
151
 
152
152
  /**
153
153
  * Describes the current state of the connection
@@ -157,6 +157,7 @@ typedef enum sp_connectionstate {
157
157
  SP_CONNECTION_STATE_LOGGED_IN = 1, ///< Logged in against a Spotify access point
158
158
  SP_CONNECTION_STATE_DISCONNECTED = 2, ///< Was logged in, but has now been disconnected
159
159
  SP_CONNECTION_STATE_UNDEFINED = 3, ///< The connection state is undefined
160
+ SP_CONNECTION_STATE_OFFLINE = 4 ///< Logged in in offline mode
160
161
  } sp_connectionstate;
161
162
 
162
163
 
@@ -195,7 +196,7 @@ typedef enum sp_playlist_type {
195
196
  SP_PLAYLIST_TYPE_PLACEHOLDER = 3, ///< Unknown entry.
196
197
  } sp_playlist_type;
197
198
 
198
- /*
199
+ /**
199
200
  * Playlist offline status
200
201
  */
201
202
  typedef enum sp_playlist_offline_status {
@@ -217,7 +218,7 @@ typedef struct sp_audio_buffer_stats {
217
218
  * List of subscribers returned by sp_playlist_subscribers()
218
219
  */
219
220
  typedef struct sp_subscribers {
220
- unsigned int count;
221
+ unsigned int count; ///< Number of elements in 'subscribers'
221
222
  char *subscribers[1]; ///< Actual size is 'count'. Array of pointers to canonical usernames
222
223
  } sp_subscribers;
223
224
 
@@ -388,7 +389,7 @@ typedef struct sp_session_callbacks {
388
389
  * @param[in] format Audio format descriptor sp_audioformat
389
390
  * @param[in] frames Points to raw PCM data as described by \p format
390
391
  * @param[in] num_frames Number of available samples in \p frames.
391
- * If this is 0, a discontinuity has occured (such as after a seek). The application
392
+ * If this is 0, a discontinuity has occurred (such as after a seek). The application
392
393
  * should flush its audio fifos, etc.
393
394
  *
394
395
  * @return Number of frames consumed.
@@ -503,11 +504,14 @@ typedef struct sp_session_callbacks {
503
504
  typedef struct sp_session_config {
504
505
  int api_version; ///< The version of the Spotify API your application is compiled with. Set to #SPOTIFY_API_VERSION
505
506
  const char *cache_location; /**< The location where Spotify will write cache files.
506
- * This cache include tracks, cached browse results and coverarts
507
+ * This cache include tracks, cached browse results and coverarts.
507
508
  * Set to empty string ("") to disable cache
508
509
  */
509
510
  const char *settings_location; /**< The location where Spotify will write setting files and per-user
510
- * cache items. This includes playlists, track metadata, etc
511
+ * cache items. This includes playlists, track metadata, etc.
512
+ * 'settings_location' may be the same path as 'cache_location'.
513
+ * 'settings_location' folder will not be created (unlike 'cache_location'),
514
+ * if you don't want to create the folder yourself, you can set 'settings_location' to 'cache_location'.
511
515
  */
512
516
  const void *application_key; ///< Your application key
513
517
  size_t application_key_size; ///< The size of the application key in bytes
@@ -525,7 +529,7 @@ typedef struct sp_session_config {
525
529
 
526
530
  /**
527
531
  * Don't save metadata for local copies of playlists
528
- * Reduces disk space usage at the expence of needing
532
+ * Reduces disk space usage at the expense of needing
529
533
  * to request metadata from Spotify backend when loading list
530
534
  */
531
535
  bool dont_save_metadata_for_playlists;
@@ -540,6 +544,7 @@ typedef struct sp_session_config {
540
544
  /**
541
545
  * Initialize a session. The session returned will be initialized, but you will need
542
546
  * to log in before you can perform any other operation
547
+ * Currently it is not supported to have multiple active sessions, and it's recommended to only call this once per process.
543
548
  *
544
549
  * Here is a snippet from \c spshell.c:
545
550
  * @dontinclude spshell.c
@@ -565,21 +570,65 @@ SP_LIBEXPORT(sp_error) sp_session_create(const sp_session_config *config, sp_ses
565
570
  */
566
571
  SP_LIBEXPORT(void) sp_session_release(sp_session *sess);
567
572
 
573
+
568
574
  /**
569
- * Logs in the specified username/password combo. This initiates the download in the background.
575
+ * Logs in the specified username/password combo. This initiates the login in the background.
570
576
  * A callback is called when login is complete
571
577
  *
578
+ * An application MUST NEVER store the user's password in clear text.
579
+ * If automatic relogin is required, use sp_session_relogin()
580
+ *
572
581
  * Here is a snippet from \c spshell.c:
573
582
  * @dontinclude spshell.c
574
583
  * @skip sp_session_login
575
584
  * @until }
576
585
  *
577
- * @param[in] session Your session object
578
- * @param[in] username The username to log in
579
- * @param[in] password The password for the specified username
586
+ * @param[in] session Your session object
587
+ * @param[in] username The username to log in
588
+ * @param[in] password The password for the specified username
589
+ * @param[in] remember_me If set, the username / password will be remembered by libspotify
590
+ *
591
+ */
592
+ SP_LIBEXPORT(void) sp_session_login(sp_session *session, const char *username, const char *password, bool remember_me);
593
+
594
+
595
+ /**
596
+ * Log in the remembered user if last user that logged in logged in with remember_me set.
597
+ * If no credentials are stored, this will return SP_ERROR_NO_CREDENTIALS.
598
+ *
599
+ * @param[in] session Your session object
600
+ *
601
+ * @return One of the following errors, from ::sp_error
602
+ * SP_ERROR_OK
603
+ * SP_ERROR_NO_CREDENTIALS
604
+ */
605
+ SP_LIBEXPORT(sp_error) sp_session_relogin(sp_session *session);
606
+
607
+
608
+ /**
609
+ * Get username of the user that will be logged in via sp_session_relogin()
610
+ *
611
+ * @param[in] session Your session object
612
+ * @param[out] buffer The buffer to hold the username
613
+ * @param[in] buffer_size The max size of the buffer that will hold the username.
614
+ * The resulting string is guaranteed to always be null terminated if
615
+ * buffer_size > 0
580
616
  *
617
+ * @return The number of characters in the username.
618
+ * If value is greater or equal than \p buffer_size, output was truncated.
619
+ * If returned value is -1 no credentials are stored in libspotify.
581
620
  */
582
- SP_LIBEXPORT(void) sp_session_login(sp_session *session, const char *username, const char *password);
621
+ SP_LIBEXPORT(int) sp_session_remembered_user(sp_session *session, char *buffer, size_t buffer_size);
622
+
623
+
624
+ /**
625
+ * Remove stored credentials in libspotify. If no credentials are currently stored, nothing will happen.
626
+ *
627
+ * @param[in] session Your session object
628
+ *
629
+ */
630
+ SP_LIBEXPORT(void) sp_session_forget_me(sp_session *session);
631
+
583
632
 
584
633
  /**
585
634
  * Fetches the currently logged in user
@@ -716,7 +765,7 @@ SP_LIBEXPORT(sp_playlistcontainer *) sp_session_playlistcontainer(sp_session *se
716
765
  *
717
766
  * @param[in] session Session object
718
767
  *
719
- * @return A playlist.
768
+ * @return A playlist or NULL if no user is logged in
720
769
  * @note You need to release the playlist when you are done with it.
721
770
  * @see sp_playlist_release()
722
771
  */
@@ -727,7 +776,7 @@ SP_LIBEXPORT(sp_playlist *) sp_session_inbox_create(sp_session *session);
727
776
  *
728
777
  * @param[in] session Session object
729
778
  *
730
- * @return A playlist.
779
+ * @return A playlist or NULL if no user is logged in
731
780
  * @note You need to release the playlist when you are done with it.
732
781
  * @see sp_playlist_release()
733
782
  */
@@ -739,7 +788,7 @@ SP_LIBEXPORT(sp_playlist *) sp_session_starred_create(sp_session *session);
739
788
  * @param[in] session Session object
740
789
  * @param[in] canonical_username Canonical username
741
790
  *
742
- * @return A playlist.
791
+ * @return A playlist or NULL if no user is logged in
743
792
  * @note You need to release the playlist when you are done with it.
744
793
  * @see sp_playlist_release()
745
794
  */
@@ -755,7 +804,7 @@ SP_LIBEXPORT(sp_playlist *) sp_session_starred_for_user_create(sp_session *sessi
755
804
  * @param[in] session Your session object.
756
805
  * @param[in] canonical_username The canonical username, or NULL.
757
806
  *
758
- * @return Playlist container object, NULL if not logged in or not found.
807
+ * @return Playlist container object, NULL if not logged in.
759
808
  */
760
809
  SP_LIBEXPORT(sp_playlistcontainer *) sp_session_publishedcontainer_for_user_create(sp_session *session, const char *canonical_username);
761
810
 
@@ -856,8 +905,21 @@ SP_LIBEXPORT(int) sp_offline_num_playlists(sp_session *session);
856
905
  * @param[in] session Session object
857
906
  * @param[out] status Status object that will be filled with info
858
907
  *
908
+ * @return false if no synching is in progress (in which case the contents
909
+ * of status is undefined)
910
+ *
911
+ */
912
+ SP_LIBEXPORT(bool) sp_offline_sync_get_status(sp_session *session, sp_offline_sync_status *status);
913
+
914
+ /**
915
+ * Return remaining time (in seconds) until the offline key store expires
916
+ * and the user is required to relogin
917
+ *
918
+ * @param[in] session Session object
919
+ * @return Seconds until expiration
920
+ *
859
921
  */
860
- SP_LIBEXPORT(void) sp_offline_sync_get_status(sp_session *session, sp_offline_sync_status *status);
922
+ SP_LIBEXPORT(int) sp_offline_time_left(sp_session *session);
861
923
 
862
924
  /**
863
925
  * Get currently logged in users country
@@ -961,6 +1023,20 @@ SP_LIBEXPORT(sp_link *) sp_link_create_from_album_cover(sp_album *album);
961
1023
  */
962
1024
  SP_LIBEXPORT(sp_link *) sp_link_create_from_artist(sp_artist *artist);
963
1025
 
1026
+ /**
1027
+ * Creates a link object pointing to an artist portrait
1028
+ *
1029
+ * @param[in] artist Artist browse object
1030
+ *
1031
+ * @return A link object representing an image
1032
+ *
1033
+ * @note You need to release the link when you are done with it.
1034
+ * @see sp_link_release()
1035
+ * @see sp_artistbrowse_num_portraits()
1036
+ */
1037
+ SP_LIBEXPORT(sp_link *) sp_link_create_from_artist_portrait(sp_artist *artist);
1038
+
1039
+
964
1040
  /**
965
1041
  * Creates a link object from an artist portrait
966
1042
  *
@@ -972,8 +1048,13 @@ SP_LIBEXPORT(sp_link *) sp_link_create_from_artist(sp_artist *artist);
972
1048
  * @note You need to release the link when you are done with it.
973
1049
  * @see sp_link_release()
974
1050
  * @see sp_artistbrowse_num_portraits()
1051
+ *
1052
+ * @note The difference from sp_link_create_from_artist_portrait() is
1053
+ * that the artist browse object may contain multiple portraits.
1054
+ *
975
1055
  */
976
- SP_LIBEXPORT(sp_link *) sp_link_create_from_artist_portrait(sp_artistbrowse *arb, int index);
1056
+ SP_LIBEXPORT(sp_link *) sp_link_create_from_artistbrowse_portrait(sp_artistbrowse *arb, int index);
1057
+
977
1058
 
978
1059
  /**
979
1060
  * Generate a link object representing the current search
@@ -1065,7 +1146,7 @@ SP_LIBEXPORT(sp_track *) sp_link_as_track(sp_link *link);
1065
1146
  * The track and offset into track representation for the given link
1066
1147
  *
1067
1148
  * @param[in] link The Spotify link whose track you are interested in
1068
- * @param[out] offset Pointer to offset into track (in seconds). If the link
1149
+ * @param[out] offset Pointer to offset into track (in milliseconds). If the link
1069
1150
  * does not contain an offset this will be set to 0.
1070
1151
  *
1071
1152
  * @return The track representation of the given track link
@@ -1135,7 +1216,7 @@ SP_LIBEXPORT(void) sp_link_release(sp_link *link);
1135
1216
  *
1136
1217
  * @return True if track is loaded
1137
1218
  *
1138
- * @note This is equivivalent to checking if sp_track_error() not returns SP_ERROR_IS_LOADING.
1219
+ * @note This is equivalent to checking if sp_track_error() not returns SP_ERROR_IS_LOADING.
1139
1220
  */
1140
1221
  SP_LIBEXPORT(bool) sp_track_is_loaded(sp_track *track);
1141
1222
 
@@ -1214,7 +1295,7 @@ SP_LIBEXPORT(bool) sp_track_is_starred(sp_session *session, sp_track *track);
1214
1295
  * @note This will fail silently if playlists are disabled.
1215
1296
  * @see sp_set_playlists_enabled()
1216
1297
  */
1217
- SP_LIBEXPORT(void) sp_track_set_starred(sp_session *session, const sp_track **tracks, int num_tracks, bool star);
1298
+ SP_LIBEXPORT(void) sp_track_set_starred(sp_session *session, sp_track *const*tracks, int num_tracks, bool star);
1218
1299
 
1219
1300
  /**
1220
1301
  * The number of artists performing on the specified track
@@ -1274,7 +1355,7 @@ SP_LIBEXPORT(int) sp_track_duration(sp_track *track);
1274
1355
  *
1275
1356
  * @param[in] track A track object
1276
1357
  *
1277
- * @return Popularity in range 0 to 100, 0 if undefined
1358
+ * @return Popularity in range 0 to 100, 0 if undefined.
1278
1359
  * If no metadata is available for the track yet, this function returns 0.
1279
1360
  */
1280
1361
  SP_LIBEXPORT(int) sp_track_popularity(sp_track *track);
@@ -1960,7 +2041,7 @@ SP_LIBEXPORT(void) sp_image_release(sp_image *image);
1960
2041
 
1961
2042
 
1962
2043
  /**
1963
- * @defgroup search Search subsysten
2044
+ * @defgroup search Search subsystem
1964
2045
  * @{
1965
2046
  */
1966
2047
 
@@ -2501,7 +2582,7 @@ SP_LIBEXPORT(bool) sp_playlist_is_collaborative(sp_playlist *playlist);
2501
2582
  /**
2502
2583
  * Set collaborative status for a playlist.
2503
2584
  *
2504
- * A playlist in collaborative state can be modifed by all users, not only the user owning the list
2585
+ * A playlist in collaborative state can be modified by all users, not only the user owning the list
2505
2586
  *
2506
2587
  * @param[in] playlist Playlist object
2507
2588
  * @param[in] collaborative True or false
@@ -2570,7 +2651,7 @@ SP_LIBEXPORT(bool) sp_playlist_has_pending_changes(sp_playlist *playlist);
2570
2651
  * SP_ERROR_INVALID_INDATA - position is > current playlist length
2571
2652
  * SP_ERROR_PERMISSION_DENIED
2572
2653
  */
2573
- SP_LIBEXPORT(sp_error) sp_playlist_add_tracks(sp_playlist *playlist, const sp_track **tracks, int num_tracks, int position, sp_session *session);
2654
+ SP_LIBEXPORT(sp_error) sp_playlist_add_tracks(sp_playlist *playlist, sp_track *const*tracks, int num_tracks, int position, sp_session *session);
2574
2655
 
2575
2656
  /**
2576
2657
  * Remove tracks from a playlist
@@ -2667,7 +2748,7 @@ SP_LIBEXPORT(void) sp_playlist_update_subscribers(sp_session *session, sp_playli
2667
2748
  * There is one caveat tough: If libspotify has never seen the
2668
2749
  * playlist before this metadata will also be unset.
2669
2750
  * In order for libspotify to get the metadata the playlist
2670
- * needs to be loaded atleast once.
2751
+ * needs to be loaded at least once.
2671
2752
  * In order words, if libspotify starts with an empty playlist
2672
2753
  * cache and the application has set 'initially_unload_playlists'
2673
2754
  * config parameter to True all playlists will be empty.
@@ -2705,7 +2786,8 @@ SP_LIBEXPORT(void) sp_playlist_set_in_ram(sp_session *session, sp_playlist *play
2705
2786
  SP_LIBEXPORT(sp_playlist *) sp_playlist_create(sp_session *session, sp_link *link);
2706
2787
 
2707
2788
  /**
2708
- * Mark a playlist to be synchronized for offline playback
2789
+ * Mark a playlist to be synchronized for offline playback.
2790
+ * The playlist must be in the users playlistcontainer
2709
2791
  *
2710
2792
  * @param[in] session Session object
2711
2793
  * @param[in] playlist Playlist object
@@ -2734,6 +2816,7 @@ SP_LIBEXPORT(sp_playlist_offline_status) sp_playlist_get_offline_status(sp_sessi
2734
2816
  * @param[in] playlist Playlist object
2735
2817
  *
2736
2818
  * @return Value from 0 - 100 that indicates amount of playlist that is downloaded
2819
+ * or 0 if the playlist is not in the SP_PLAYLIST_OFFLINE_STATUS_DOWNLOADING mode.
2737
2820
  *
2738
2821
  * @see sp_playlist_offline_status()
2739
2822
  */
@@ -2812,7 +2895,7 @@ typedef struct sp_playlistcontainer_callbacks {
2812
2895
  * @param[in] callbacks Callbacks, see sp_playlistcontainer_callbacks
2813
2896
  * @param[in] userdata Opaque value passed to callbacks.
2814
2897
  *
2815
- * @note Every sp_playlistcontainer_add_callbacks() needs to be paried with a corresponding
2898
+ * @note Every sp_playlistcontainer_add_callbacks() needs to be paired with a corresponding
2816
2899
  * sp_playlistcontainer_remove_callbacks() that is invoked before releasing the
2817
2900
  * last reference you own for the container. In other words, you must make sure
2818
2901
  * to have removed all the callbacks before the container gets destroyed.
@@ -2863,7 +2946,7 @@ SP_LIBEXPORT(bool) sp_playlistcontainer_is_loaded(sp_playlistcontainer *pc);
2863
2946
  * @param[in] pc Playlist container
2864
2947
  * @param[in] index Index in playlist container. Should be in the interval [0, sp_playlistcontainer_num_playlists() - 1]
2865
2948
  *
2866
- * @return Number of playlists.
2949
+ * @return The playlist object
2867
2950
  *
2868
2951
  * @sa sp_session_playlistcontainer()
2869
2952
  */
@@ -2885,11 +2968,12 @@ SP_LIBEXPORT(sp_playlist_type) sp_playlistcontainer_playlist_type(sp_playlistcon
2885
2968
  * Return the folder name at @a index
2886
2969
  *
2887
2970
  * @param[in] pc Playlist container
2888
- * @param[in] index Index in playlist container. Should be in the interval [0, sp_playlistcontainer_num_playlists() - 1]
2971
+ * @param[in] index Index in playlist container. Should be in the interval [0, sp_playlistcontainer_num_playlists() - 1].
2972
+ * Index should point at a start-folder entry, otherwise the empty string is written to buffer.
2889
2973
  * @param[in] buffer Pointer to char[] where to store folder name
2890
2974
  * @param[in] buffer_size Size of array
2891
2975
  *
2892
- * @return error One of the following errors, from ::sp_error
2976
+ * @return One of the following errors, from ::sp_error
2893
2977
  * SP_ERROR_OK
2894
2978
  * SP_ERROR_INDEX_OUT_OF_RANGE
2895
2979
  *
@@ -2903,7 +2987,7 @@ SP_LIBEXPORT(sp_error) sp_playlistcontainer_playlist_folder_name(sp_playlistcont
2903
2987
  * @param[in] pc Playlist container
2904
2988
  * @param[in] index Index in playlist container. Should be in the interval [0, sp_playlistcontainer_num_playlists() - 1]
2905
2989
  *
2906
- * @return The group ID
2990
+ * @return The group ID of the folder. Returns 0 on index out of range, pc being NULL or indexed item not being a folder
2907
2991
  *
2908
2992
  * @sa sp_session_playlistcontainer()
2909
2993
  */
@@ -3122,7 +3206,7 @@ typedef enum {
3122
3206
  * country codes (in uppercase) encoded in an integer. There are also some reserved
3123
3207
  * codes used to denote non-country regions. See sp_toplistregion
3124
3208
  *
3125
- * Example: SP_TOPLIST_REGION('S', 'E') // for sweden
3209
+ * Example: SP_TOPLIST_REGION('S', 'E') for Sweden
3126
3210
  */
3127
3211
  #define SP_TOPLIST_REGION(a, b) ((a) << 8 | (b))
3128
3212
 
@@ -3270,7 +3354,7 @@ SP_LIBEXPORT(sp_track *) sp_toplistbrowse_track(sp_toplistbrowse *tlb, int index
3270
3354
  /** @} */
3271
3355
 
3272
3356
  /**
3273
- * @defgroup inbox Inbox subsysten
3357
+ * @defgroup inbox Inbox subsystem
3274
3358
  * @{
3275
3359
  */
3276
3360
 
@@ -3291,7 +3375,7 @@ typedef void SP_CALLCONV inboxpost_complete_cb(sp_inbox *result, void *userdata)
3291
3375
  *
3292
3376
  * @param[in] session Session object
3293
3377
  * @param[in] user Canonical username of recipient
3294
- * @param[in] tracks Array of trancks to post
3378
+ * @param[in] tracks Array of tracks to post
3295
3379
  * @param[in] num_tracks Number of tracks in \p tracks
3296
3380
  * @param[in] message Message to attach to tracks. UTF-8
3297
3381
  * @param[in] callback Callback to be invoked when the request has completed
@@ -3334,6 +3418,14 @@ SP_LIBEXPORT(void) sp_inbox_release(sp_inbox *inbox);
3334
3418
 
3335
3419
  /** @} */
3336
3420
 
3421
+ /**
3422
+ * Return the libspotify build ID
3423
+ *
3424
+ * This might be useful to have available for display somewhere in your
3425
+ * user interface.
3426
+ */
3427
+ SP_LIBEXPORT(const char *) sp_build_id(void);
3428
+
3337
3429
 
3338
3430
  #ifdef __cplusplus
3339
3431
  }
File without changes
File without changes
File without changes
@@ -2,6 +2,11 @@
2
2
 
3
3
  /*** Spotify API ***/
4
4
 
5
+ const char * sp_build_id(void)
6
+ {
7
+ return "9.1.32.g8edbd53c Release (Core: 0.5.3.425.g18537e22)";
8
+ }
9
+
5
10
  sp_error
6
11
  sp_session_create(const sp_session_config * config, sp_session ** sess)
7
12
  {
@@ -52,9 +57,13 @@ sp_session_userdata(sp_session *session)
52
57
  }
53
58
 
54
59
  void
55
- sp_session_login(sp_session *session, const char *username, const char *password)
60
+ sp_session_login(sp_session *session, const char *username, const char *password, bool remember_me)
56
61
  {
57
62
  session->connectionstate = SP_CONNECTION_STATE_LOGGED_IN;
63
+ if (remember_me)
64
+ {
65
+ my_strncpy(session->username, username, 1024);
66
+ }
58
67
  }
59
68
 
60
69
  void
@@ -126,12 +126,14 @@ sp_track_is_starred(sp_session *s, sp_track *t)
126
126
  }
127
127
 
128
128
  void
129
- sp_track_set_starred(sp_session *s, const sp_track **ts, int n, bool starred)
129
+ sp_track_set_starred(sp_session *s, sp_track *const*tracks, int num_tracks, bool starred)
130
130
  {
131
131
  int i;
132
132
 
133
- for (i = 0; i < n; i++)
134
- ((sp_track *) ts[i])->starred = starred;
133
+ for (i = 0; i < num_tracks; i++)
134
+ {
135
+ tracks[i]->starred = starred;
136
+ }
135
137
  }
136
138
 
137
139
  void
File without changes
@@ -51,3 +51,10 @@ atohex(char *dst, const char *src, int size)
51
51
  dst[i+1] = itoh(src[p] & 0xF);
52
52
  }
53
53
  }
54
+
55
+ void
56
+ my_strncpy(char *destination, const char *source, size_t size)
57
+ {
58
+ strncpy(destination, source, size - 2);
59
+ destination[size - 1] = '\0';
60
+ }
@@ -9,6 +9,7 @@
9
9
  #define MEMCPY_N(dst, src, type, n) (memcpy((dst), (src), sizeof(type) * (n)))
10
10
  void *xmalloc(size_t);
11
11
  char *hextoa(const char *, int);
12
+ void my_strncpy(char *, const char *, size_t);
12
13
 
13
14
  #define STARTS_WITH(x, y) (strncmp((x), (y), strlen(y)) == 0)
14
15
 
data/lib/mockspotify.rb CHANGED
@@ -6,7 +6,7 @@ module Spotify
6
6
  module Mock
7
7
  # @return [String] path to the libmockspotify C extension binary.
8
8
  def self.path
9
- File.expand_path('../../src/libmockspotify.', __FILE__) << Config::MAKEFILE_CONFIG['DLEXT']
9
+ File.expand_path('../../ext/libmockspotify.', __FILE__) << Config::MAKEFILE_CONFIG['DLEXT']
10
10
  end
11
11
 
12
12
  # Overridden to always ffi_lib the mock path.
@@ -26,7 +26,8 @@ module Spotify
26
26
  extend Mock
27
27
  require 'spotify'
28
28
 
29
- $VERBOSE = true
29
+ old_verbose, $VERBOSE = $VERBOSE, true
30
+
30
31
  attach_function :mock_user, :mocksp_user_create, [:string, :string, :string, :string, :relation_type, :bool], :user
31
32
  attach_function :mock_track, :mocksp_track_create, [:string, :int, :array, :pointer, :int, :int, :int, :int, :error, :bool], :track
32
33
  attach_function :mock_image, :mocksp_image_create, [:image_id, :imageformat, :size_t, :buffer_in, :error], :image
@@ -36,5 +37,6 @@ module Spotify
36
37
  attach_function :mock_artistbrowse, :mocksp_artistbrowse_create, [:artist, :bool], :artistbrowse
37
38
 
38
39
  attach_function :mock_playlist_event, :mocksp_playlist_event, [:int, :playlist], :void
39
- $VERBOSE = false
40
+
41
+ $VERBOSE = old_verbose
40
42
  end
@@ -1,5 +1,5 @@
1
1
  module Spotify
2
2
  module Mock
3
- VERSION = '0.1.9'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
data/mockspotify.gemspec CHANGED
@@ -1,17 +1,20 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/mockspotify/version', __FILE__)
2
+ libpath = File.expand_path('../lib', __FILE__)
3
+ $:.unshift libpath unless $:.include?(libpath)
4
+ require 'mockspotify/version'
3
5
 
4
6
  Gem::Specification.new do |gem|
5
7
  gem.name = "mockspotify"
6
- gem.summary = %Q{A mock of libspotify for use in development of language bindings}
7
- gem.homepage = "https://github.com/Burgestrand/libmockspotify"
8
+ gem.summary = %Q{FFI bindings to the mockspotify C library}
9
+ gem.homepage = "https://github.com/Burgestrand/mockspotify"
8
10
  gem.authors = ["Kim Burgestrand"]
9
11
  gem.email = 'kim@burgestrand.se'
10
12
 
11
13
  gem.files = `git ls-files`.split("\n")
14
+ gem.files += `cd ext/libmockspotify && git ls-files src/`.split("\n").map { |path| "ext/libmockspotify/#{path}" }
12
15
  gem.executables = []
13
- gem.require_paths = ["lib", "src"]
14
- gem.extensions << 'src/extconf.rb'
16
+ gem.require_paths = ["lib"]
17
+ gem.extensions << 'ext/extconf.rb'
15
18
 
16
19
  gem.add_dependency 'spotify'
17
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mockspotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-28 00:00:00.000000000Z
12
+ date: 2011-09-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spotify
16
- requirement: &2156420600 !ruby/object:Gem::Requirement
16
+ requirement: &2157780240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,50 +21,46 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156420600
24
+ version_requirements: *2157780240
25
25
  description:
26
26
  email: kim@burgestrand.se
27
27
  executables: []
28
28
  extensions:
29
- - src/extconf.rb
29
+ - ext/extconf.rb
30
30
  extra_rdoc_files: []
31
31
  files:
32
32
  - .gitignore
33
+ - .gitmodules
33
34
  - Gemfile
34
- - Makefile.am
35
- - README.rst
36
35
  - Rakefile
37
- - autogen.sh
38
- - configure.ac
36
+ - ext/extconf.rb
39
37
  - lib/mockspotify.rb
40
38
  - lib/mockspotify/version.rb
41
39
  - mockspotify.gemspec
42
- - src/Makefile.am
43
- - src/album.c
44
- - src/albumbrowse.c
45
- - src/artist.c
46
- - src/artistbrowse.c
47
- - src/error.c
48
- - src/extconf.rb
49
- - src/image.c
50
- - src/libmockspotify.h
51
- - src/libspotify/api.h
52
- - src/link.c
53
- - src/playlist.c
54
- - src/search.c
55
- - src/session.c
56
- - src/track.c
57
- - src/user.c
58
- - src/util.c
59
- - src/util.h
60
40
  - test/mockspotify_spec.rb
61
- homepage: https://github.com/Burgestrand/libmockspotify
41
+ - ext/libmockspotify/src/Makefile.am
42
+ - ext/libmockspotify/src/album.c
43
+ - ext/libmockspotify/src/albumbrowse.c
44
+ - ext/libmockspotify/src/artist.c
45
+ - ext/libmockspotify/src/artistbrowse.c
46
+ - ext/libmockspotify/src/error.c
47
+ - ext/libmockspotify/src/image.c
48
+ - ext/libmockspotify/src/libmockspotify.h
49
+ - ext/libmockspotify/src/libspotify/api.h
50
+ - ext/libmockspotify/src/link.c
51
+ - ext/libmockspotify/src/playlist.c
52
+ - ext/libmockspotify/src/search.c
53
+ - ext/libmockspotify/src/session.c
54
+ - ext/libmockspotify/src/track.c
55
+ - ext/libmockspotify/src/user.c
56
+ - ext/libmockspotify/src/util.c
57
+ - ext/libmockspotify/src/util.h
58
+ homepage: https://github.com/Burgestrand/mockspotify
62
59
  licenses: []
63
60
  post_install_message:
64
61
  rdoc_options: []
65
62
  require_paths:
66
63
  - lib
67
- - src
68
64
  required_ruby_version: !ruby/object:Gem::Requirement
69
65
  none: false
70
66
  requirements:
@@ -79,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
75
  version: '0'
80
76
  requirements: []
81
77
  rubyforge_project:
82
- rubygems_version: 1.8.5
78
+ rubygems_version: 1.8.6
83
79
  signing_key:
84
80
  specification_version: 3
85
- summary: A mock of libspotify for use in development of language bindings
81
+ summary: FFI bindings to the mockspotify C library
86
82
  test_files: []
data/Makefile.am DELETED
@@ -1,3 +0,0 @@
1
- SUBDIRS = src
2
-
3
- ACLOCAL_AMFLAGS = -I m4
data/README.rst DELETED
@@ -1,55 +0,0 @@
1
- libmockspotify
2
- ==============
3
-
4
- A mock of libspotify for use in development of language bindings.
5
-
6
- This project was started in July 2011 with the goal of splitting out
7
- pyspotify's mock of libspotify, so that it could be reused by the developers of
8
- the Node.js and Ruby bindings for libspotify.
9
-
10
- Coordination of the development efforts happens on GitHub and #spotify on
11
- Freenode.
12
-
13
- Note about my fork
14
- ------------------
15
- To ease usage in my own development, I’ve turned this project into a
16
- Ruby gem. This allows you to install it as a gem, and also allows you
17
- to retrieve the path to the compiled binary.
18
-
19
- Installing it as a gem:
20
-
21
- ::
22
-
23
- gem install mockspotify
24
-
25
- Using its’ API (one method):
26
-
27
- ::
28
-
29
- require 'mockspotify'
30
- MockSpotify.lib_path # => path/to/gem/src/libmockspotify.extension
31
-
32
- You can then use this to bind this library using Ruby FFI:
33
-
34
- ::
35
-
36
- require 'ffi'
37
- require 'mockspotify'
38
-
39
- module Spotify
40
- extend FFI::Library
41
- ffi_lib MockSpotify.lib_path
42
-
43
- attach_function …, etc
44
- end
45
-
46
- Manual compilation
47
- ------------------
48
- If you ever want to do it, here you go:
49
-
50
- ::
51
-
52
- $ ./autogen.sh
53
- $ ./configure
54
- $ make
55
- # make install
data/autogen.sh DELETED
@@ -1,4 +0,0 @@
1
- #! /bin/sh
2
-
3
- libtoolize \
4
- && autoreconf --install
data/configure.ac DELETED
@@ -1,10 +0,0 @@
1
- AC_INIT([libmockspotify], [0.1], [http://github.com/mopidy/libmockspotify])
2
- AM_INIT_AUTOMAKE([foreign -Wall -Werror])
3
-
4
- AC_PROG_CC
5
- AC_PROG_LIBTOOL
6
-
7
- AC_CONFIG_MACRO_DIR([m4])
8
- AC_CONFIG_HEADERS([config.h])
9
- AC_CONFIG_FILES([Makefile src/Makefile])
10
- AC_OUTPUT
data/src/extconf.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'mkmf'
2
-
3
- $CFLAGS << ' -O0 -ggdb -Wextra '
4
-
5
- create_makefile 'libmockspotify'