mockspotify 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mockspotify.rb CHANGED
@@ -31,7 +31,7 @@ module Spotify
31
31
  attach_function :mock_track, :mocksp_track_create, [:string, :int, :array, :pointer, :int, :int, :int, :int, :error, :bool], :track
32
32
  attach_function :mock_image, :mocksp_image_create, [:image_id, :imageformat, :size_t, :buffer_in, :error], :image
33
33
  attach_function :mock_artist, :mocksp_artist_create, [:string, :bool], :artist
34
- attach_function :mock_album, :mocksp_album_create, [:string, :artist, :int, :pointer, :image_id, :albumtype, :bool, :bool], :album
34
+ attach_function :mock_album, :mocksp_album_create, [:string, :artist, :int, :image_id, :albumtype, :bool, :bool], :album
35
35
 
36
36
  attach_function :mock_artistbrowse, :mocksp_artistbrowse_create, [:artist, :bool], :artistbrowse
37
37
 
@@ -1,5 +1,5 @@
1
1
  module Spotify
2
2
  module Mock
3
- VERSION = '0.1.6'
3
+ VERSION = '0.1.7'
4
4
  end
5
5
  end
data/src/album.c CHANGED
@@ -13,7 +13,7 @@ mocksp_album_create(const char *name, sp_artist *artist, int year, const byte *c
13
13
  strcpy(a->name, name);
14
14
  a->artist = artist;
15
15
  a->year = year;
16
- memcpy(a->cover, cover, 20);
16
+ if (cover) memcpy(a->cover, cover, 20);
17
17
  a->type = type;
18
18
  a->loaded = loaded;
19
19
  a->available = available;
data/src/libmockspotify.h CHANGED
@@ -80,7 +80,7 @@ struct sp_search {
80
80
  struct sp_track {
81
81
  char name[1024];
82
82
  int num_artists;
83
- sp_artist *artists[16];
83
+ sp_artist **artists;
84
84
  sp_album *album;
85
85
  int duration;
86
86
  int popularity;
data/src/track.c CHANGED
@@ -21,11 +21,29 @@ mocksp_track_create(const char *name, int num_artists, sp_artist **artists,
21
21
  t->album = album;
22
22
  t->starred = 0;
23
23
 
24
+ t->artists = ALLOC_N(sp_artist*, num_artists);
25
+ MEMCPY_N(t->artists, artists, sp_artist*, num_artists);
26
+ t->num_artists = num_artists;
27
+
24
28
  return t;
25
29
  }
26
30
 
27
31
  /*** Spotify API ***/
28
32
 
33
+ sp_track *
34
+ sp_localtrack_create(const char *artist, const char *title, const char *album, int length)
35
+ {
36
+ sp_artist *partist = mocksp_artist_create(artist, 1);
37
+ sp_album *palbum = NULL;
38
+
39
+ if (strlen(album) > 0)
40
+ {
41
+ palbum = mocksp_album_create(album, partist, 2011, NULL, SP_ALBUMTYPE_UNKNOWN, 1, 1);
42
+ }
43
+
44
+ return mocksp_track_create(title, 1, &partist, palbum, length, 0, 0, 0, 0, 1);
45
+ }
46
+
29
47
  bool
30
48
  sp_track_is_available(sp_session *session, sp_track *t)
31
49
  {
@@ -47,18 +65,16 @@ sp_track_name(sp_track *track)
47
65
  int
48
66
  sp_track_num_artists(sp_track *t)
49
67
  {
50
- return 3;
68
+ return t->num_artists;
51
69
  }
52
70
 
53
71
  sp_artist *
54
72
  sp_track_artist(sp_track *t, int index)
55
73
  {
56
- static sp_artist *a[3];
74
+ if (index >= sp_track_num_artists(t))
75
+ return NULL;
57
76
 
58
- a[0] = mocksp_artist_create("a1", 1);
59
- a[1] = mocksp_artist_create("a2", 1);
60
- a[2] = mocksp_artist_create("a3", 1);
61
- return a[index];
77
+ return t->artists[index];
62
78
  }
63
79
 
64
80
  int
data/src/util.h CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  #define ALLOC(type) ALLOC_N(type, 1)
7
7
  #define ALLOC_N(type, n) ((type*) xmalloc(sizeof(type) * (n)))
8
+ #define MEMCPY(dst, src, type) MEMCPY_N(dst, src, type, 1)
9
+ #define MEMCPY_N(dst, src, type, n) (memcpy((dst), (src), sizeof(type) * (n)))
8
10
  void *xmalloc(size_t);
9
11
  char *hextoa(const char *, int);
10
12
 
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.6
4
+ version: 0.1.7
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-24 00:00:00.000000000Z
12
+ date: 2011-07-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spotify
16
- requirement: &2156420020 !ruby/object:Gem::Requirement
16
+ requirement: &2154623200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156420020
24
+ version_requirements: *2154623200
25
25
  description:
26
26
  email: kim@burgestrand.se
27
27
  executables: []