mockspotify 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/src/track.c ADDED
@@ -0,0 +1,130 @@
1
+ #include <stdlib.h>
2
+ #include <string.h>
3
+ #include "libmockspotify.h"
4
+
5
+ /*** MockSpotify API ***/
6
+
7
+ sp_track *
8
+ mocksp_track_create(char *name, int num_artists, sp_artist **artists,
9
+ sp_album *album, int duration, int popularity,
10
+ int disc, int index, sp_error error, int loaded)
11
+ {
12
+ sp_track *t;
13
+
14
+ t = malloc(sizeof(sp_track));
15
+ memset(t, 0, sizeof(sp_track));
16
+ strcpy(t->name, name);
17
+ t->loaded = loaded;
18
+ t->disc = disc;
19
+ t->index = index;
20
+ t->error = error;
21
+ t->duration = duration;
22
+ t->popularity = popularity;
23
+ t->album = album;
24
+ t->starred = 0;
25
+ return t;
26
+ }
27
+
28
+ /*** Spotify API ***/
29
+
30
+ bool
31
+ sp_track_is_available(sp_session *session, sp_track *t)
32
+ {
33
+ return 1;
34
+ }
35
+
36
+ bool
37
+ sp_track_is_loaded(sp_track *t)
38
+ {
39
+ return t->loaded;
40
+ }
41
+
42
+ const char *
43
+ sp_track_name(sp_track *track)
44
+ {
45
+ return track->name;
46
+ }
47
+
48
+ int
49
+ sp_track_num_artists(sp_track *t)
50
+ {
51
+ return 3;
52
+ }
53
+
54
+ sp_artist *
55
+ sp_track_artist(sp_track *t, int index)
56
+ {
57
+ static sp_artist *a[3];
58
+
59
+ a[0] = mocksp_artist_create("a1", 1);
60
+ a[1] = mocksp_artist_create("a2", 1);
61
+ a[2] = mocksp_artist_create("a3", 1);
62
+ return a[index];
63
+ }
64
+
65
+ int
66
+ sp_track_disc(sp_track *t)
67
+ {
68
+ return t->disc;
69
+ }
70
+
71
+ int
72
+ sp_track_index(sp_track *t)
73
+ {
74
+ return t->index;
75
+ }
76
+
77
+ int
78
+ sp_track_popularity(sp_track *t)
79
+ {
80
+ return t->popularity;
81
+ }
82
+
83
+ int
84
+ sp_track_duration(sp_track *t)
85
+ {
86
+ return t->duration;
87
+ }
88
+
89
+ sp_error
90
+ sp_track_error(sp_track *t)
91
+ {
92
+ return t->error;
93
+ }
94
+
95
+ sp_album *
96
+ sp_track_album(sp_track *t)
97
+ {
98
+ return t->album;
99
+ }
100
+
101
+ bool
102
+ sp_track_is_local(sp_session *s, sp_track *t)
103
+ {
104
+ return 0;
105
+ }
106
+
107
+ bool
108
+ sp_track_is_starred(sp_session *s, sp_track *t)
109
+ {
110
+ return t->starred;
111
+ }
112
+
113
+ void
114
+ sp_track_set_starred(sp_session *s, const sp_track **ts, int n, bool starred)
115
+ {
116
+ int i;
117
+
118
+ for (i = 0; i < n; i++)
119
+ ((sp_track *) ts[i])->starred = starred;
120
+ }
121
+
122
+ void
123
+ sp_track_add_ref(sp_track *track)
124
+ {
125
+ }
126
+
127
+ void
128
+ sp_track_release(sp_track *track)
129
+ {
130
+ }
data/src/user.c ADDED
@@ -0,0 +1,69 @@
1
+ #include <stdlib.h>
2
+ #include <string.h>
3
+ #include "libmockspotify.h"
4
+
5
+ /*** MockSpotify API ***/
6
+
7
+ sp_user *
8
+ mocksp_user_create(char *canonical_name, char *display_name, char *full_name,
9
+ char *picture, sp_relation_type relation, bool loaded)
10
+ {
11
+ sp_user *user = ALLOC(sp_user);
12
+
13
+ user->canonical_name = canonical_name;
14
+ user->display_name = display_name;
15
+ user->full_name = full_name;
16
+ user->picture = picture;
17
+ user->relation = relation;
18
+ user->loaded = loaded;
19
+
20
+ return user;
21
+ }
22
+
23
+ /*** Spotify API ***/
24
+
25
+ void
26
+ sp_user_add_ref(sp_user *user)
27
+ {
28
+ }
29
+
30
+ void
31
+ sp_user_release(sp_user *user)
32
+ {
33
+ }
34
+
35
+ bool
36
+ sp_user_is_loaded(sp_user *user)
37
+ {
38
+ return user->loaded;
39
+ }
40
+
41
+ const char *
42
+ sp_user_canonical_name(sp_user *user)
43
+ {
44
+ return user->canonical_name;
45
+ }
46
+
47
+ const char *
48
+ sp_user_display_name(sp_user *user)
49
+ {
50
+ return user->display_name;
51
+ }
52
+
53
+ const char *
54
+ sp_user_full_name(sp_user *user)
55
+ {
56
+ return user->loaded ? user->full_name : NULL;
57
+ }
58
+
59
+ const char *
60
+ sp_user_picture(sp_user *user)
61
+ {
62
+ return user->loaded ? user->picture : NULL;
63
+ }
64
+
65
+ sp_relation_type
66
+ sp_user_relation_type(sp_session *session, sp_user *user)
67
+ {
68
+ return user->relation;
69
+ }
data/src/util.c ADDED
@@ -0,0 +1,11 @@
1
+ #include <stdlib.h>
2
+ #include <string.h>
3
+ #include "util.h"
4
+
5
+ void*
6
+ xmalloc(size_t size)
7
+ {
8
+ void *ptr = malloc(size);
9
+ memset(ptr, 0, size);
10
+ return ptr;
11
+ }
data/src/util.h ADDED
@@ -0,0 +1,12 @@
1
+ #ifndef UTIL_H
2
+ #define UTIL_H
3
+
4
+ /*** Utility functions ***/
5
+
6
+ #define ALLOC(type) ALLOC_N(type, 1)
7
+ #define ALLOC_N(type, n) ((type*) xmalloc(sizeof(type) * (n)))
8
+ void *xmalloc(size_t);
9
+
10
+ #define STARTS_WITH(x, y) (strncmp((x), (y), strlen(y)) == 0)
11
+
12
+ #endif /* UTIL_H */
@@ -0,0 +1,12 @@
1
+ require 'mockspotify'
2
+ require 'minitest/autorun'
3
+
4
+ describe MockSpotify do
5
+ it "should define VERSION" do
6
+ MockSpotify::VERSION.must_be_kind_of String
7
+ end
8
+
9
+ it "should provide a path to libmockspotify" do
10
+ File.exist?(MockSpotify.lib_path).must_equal true
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mockspotify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kim Burgestrand
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-07-20 00:00:00.000000000Z
13
+ dependencies: []
14
+ description:
15
+ email: kim@burgestrand.se
16
+ executables: []
17
+ extensions:
18
+ - src/extconf.rb
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - Makefile.am
24
+ - README.rst
25
+ - Rakefile
26
+ - autogen.sh
27
+ - configure.ac
28
+ - lib/mockspotify.rb
29
+ - mockspotify.gemspec
30
+ - src/Makefile.am
31
+ - src/album.c
32
+ - src/albumbrowse.c
33
+ - src/artist.c
34
+ - src/artistbrowse.c
35
+ - src/error.c
36
+ - src/extconf.rb
37
+ - src/image.c
38
+ - src/libmockspotify.h
39
+ - src/link.c
40
+ - src/playlist.c
41
+ - src/search.c
42
+ - src/session.c
43
+ - src/track.c
44
+ - src/user.c
45
+ - src/util.c
46
+ - src/util.h
47
+ - test/mockspotify_spec.rb
48
+ homepage: https://github.com/Burgestrand/libmockspotify
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ - src
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 1.8.5
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: A mock of libspotify for use in development of language bindings
73
+ test_files: []