~ubuntu-branches/ubuntu/wily/pianobar/wily-proposed

« back to all changes in this revision

Viewing changes to src/libpiano/piano.h

  • Committer: Bazaar Package Importer
  • Author(s): Luke Faraone
  • Date: 2011-02-08 17:23:25 UTC
  • mfrom: (1.3.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110208172325-0qf3sxpsu37j5ez9
Tags: 2011.01.24-1
* New upstream version. 
* Switch to DEP5 copyright.
* Augment CFLAGS to use the c99 standard.
* Don't install the now-removed AUTHORS file into docs.
* Drop dep on cmake.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2008-2010
 
3
        Lars-Dominik Braun <lars@6xq.net>
 
4
 
 
5
Permission is hereby granted, free of charge, to any person obtaining a copy
 
6
of this software and associated documentation files (the "Software"), to deal
 
7
in the Software without restriction, including without limitation the rights
 
8
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
9
copies of the Software, and to permit persons to whom the Software is
 
10
furnished to do so, subject to the following conditions:
 
11
 
 
12
The above copyright notice and this permission notice shall be included in
 
13
all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
18
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
19
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
20
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
21
THE SOFTWARE.
 
22
*/
 
23
 
 
24
#ifndef _PIANO_H
 
25
#define _PIANO_H
 
26
 
 
27
/* this is our public API; don't expect this api to be stable as long as
 
28
 * pandora does not provide a stable api
 
29
 * all strings _must_ be utf-8 encoded. i won't care, but pandora does. so
 
30
 * be nice and check the encoding of your strings. thanks :) */
 
31
 
 
32
#define PIANO_RPC_HOST "www.pandora.com"
 
33
#define PIANO_RPC_PORT "80"
 
34
 
 
35
typedef struct PianoUserInfo {
 
36
        char *webAuthToken;
 
37
        char *listenerId;
 
38
        char *authToken;
 
39
} PianoUserInfo_t;
 
40
 
 
41
typedef struct PianoStation {
 
42
        char isCreator;
 
43
        char isQuickMix;
 
44
        char useQuickMix; /* station will be included in quickmix */
 
45
        char *name;
 
46
        char *id;
 
47
        struct PianoStation *next;
 
48
} PianoStation_t;
 
49
 
 
50
typedef enum {
 
51
        PIANO_RATE_NONE = 0,
 
52
        PIANO_RATE_LOVE = 1,
 
53
        PIANO_RATE_BAN = 2
 
54
} PianoSongRating_t;
 
55
 
 
56
/* UNKNOWN should be 0, because memset sets audio format to 0 */
 
57
typedef enum {
 
58
        PIANO_AF_UNKNOWN = 0,
 
59
        PIANO_AF_AACPLUS = 1,
 
60
        PIANO_AF_MP3 = 2,
 
61
        PIANO_AF_MP3_HI = 3
 
62
} PianoAudioFormat_t;
 
63
 
 
64
typedef struct PianoSong {
 
65
        char *artist;
 
66
        char *artistMusicId;
 
67
        char *stationId;
 
68
        char *album;
 
69
        char *userSeed;
 
70
        char *audioUrl;
 
71
        char *coverArt;
 
72
        char *musicId;
 
73
        char *title;
 
74
        float fileGain;
 
75
        PianoSongRating_t rating;
 
76
        PianoAudioFormat_t audioFormat;
 
77
        int testStrategy;
 
78
        unsigned int songType;
 
79
        struct PianoSong *next;
 
80
} PianoSong_t;
 
81
 
 
82
/* currently only used for search results */
 
83
typedef struct PianoArtist {
 
84
        char *name;
 
85
        char *musicId;
 
86
        int score;
 
87
        struct PianoArtist *next;
 
88
} PianoArtist_t;
 
89
 
 
90
typedef struct PianoGenre {
 
91
        char *name;
 
92
        char *musicId;
 
93
        struct PianoGenre *next;
 
94
} PianoGenre_t;
 
95
 
 
96
typedef struct PianoGenreCategory {
 
97
        char *name;
 
98
        PianoGenre_t *genres;
 
99
        struct PianoGenreCategory *next;
 
100
} PianoGenreCategory_t;
 
101
 
 
102
typedef struct PianoHandle {
 
103
        char routeId[9];
 
104
        PianoUserInfo_t user;
 
105
        /* linked lists */
 
106
        PianoStation_t *stations;
 
107
        PianoGenreCategory_t *genreStations;
 
108
        int timeOffset;
 
109
} PianoHandle_t;
 
110
 
 
111
typedef struct PianoSearchResult {
 
112
        PianoSong_t *songs;
 
113
        PianoArtist_t *artists;
 
114
} PianoSearchResult_t;
 
115
 
 
116
typedef enum {
 
117
        /* 0 is reserved: memset (x, 0, sizeof (x)) */
 
118
        PIANO_REQUEST_LOGIN = 1,
 
119
        PIANO_REQUEST_GET_STATIONS = 2,
 
120
        PIANO_REQUEST_GET_PLAYLIST = 3,
 
121
        PIANO_REQUEST_RATE_SONG = 4,
 
122
        PIANO_REQUEST_ADD_FEEDBACK = 5,
 
123
        PIANO_REQUEST_MOVE_SONG = 6,
 
124
        PIANO_REQUEST_RENAME_STATION = 7,
 
125
        PIANO_REQUEST_DELETE_STATION = 8,
 
126
        PIANO_REQUEST_SEARCH = 9,
 
127
        PIANO_REQUEST_CREATE_STATION = 10,
 
128
        PIANO_REQUEST_ADD_SEED = 11,
 
129
        PIANO_REQUEST_ADD_TIRED_SONG = 12,
 
130
        PIANO_REQUEST_SET_QUICKMIX = 13,
 
131
        PIANO_REQUEST_GET_GENRE_STATIONS = 14,
 
132
        PIANO_REQUEST_TRANSFORM_STATION = 15,
 
133
        PIANO_REQUEST_EXPLAIN = 16,
 
134
        PIANO_REQUEST_GET_SEED_SUGGESTIONS = 17,
 
135
        PIANO_REQUEST_BOOKMARK_SONG = 18,
 
136
        PIANO_REQUEST_BOOKMARK_ARTIST = 19,
 
137
} PianoRequestType_t;
 
138
 
 
139
typedef struct PianoRequest {
 
140
        PianoRequestType_t type;
 
141
        void *data;
 
142
        char urlPath[1024];
 
143
        char *postData;
 
144
        char *responseData;
 
145
} PianoRequest_t;
 
146
 
 
147
/* request data structures */
 
148
typedef struct {
 
149
        char *user;
 
150
        char *password;
 
151
        unsigned char step;
 
152
} PianoRequestDataLogin_t;
 
153
 
 
154
typedef struct {
 
155
        PianoStation_t *station;
 
156
        PianoAudioFormat_t format;
 
157
        PianoSong_t *retPlaylist;
 
158
} PianoRequestDataGetPlaylist_t;
 
159
 
 
160
typedef struct {
 
161
        PianoSong_t *song;
 
162
        PianoSongRating_t rating;
 
163
} PianoRequestDataRateSong_t;
 
164
 
 
165
typedef struct {
 
166
        char *stationId;
 
167
        char *musicId;
 
168
        char *userSeed;
 
169
        PianoSongRating_t rating;
 
170
        unsigned int testStrategy;
 
171
        unsigned int songType;
 
172
} PianoRequestDataAddFeedback_t;
 
173
 
 
174
typedef struct {
 
175
        PianoSong_t *song;
 
176
        PianoStation_t *from;
 
177
        PianoStation_t *to;
 
178
        unsigned short step;
 
179
} PianoRequestDataMoveSong_t;
 
180
 
 
181
typedef struct {
 
182
        PianoStation_t *station;
 
183
        char *newName;
 
184
} PianoRequestDataRenameStation_t;
 
185
 
 
186
typedef struct {
 
187
        char *searchStr;
 
188
        PianoSearchResult_t searchResult;
 
189
} PianoRequestDataSearch_t;
 
190
 
 
191
typedef struct {
 
192
        char *type;
 
193
        char *id;
 
194
} PianoRequestDataCreateStation_t;
 
195
 
 
196
typedef struct {
 
197
        PianoStation_t *station;
 
198
        char *musicId;
 
199
} PianoRequestDataAddSeed_t;
 
200
 
 
201
typedef struct {
 
202
        PianoSong_t *song;
 
203
        char *retExplain;
 
204
} PianoRequestDataExplain_t;
 
205
 
 
206
typedef struct {
 
207
        char *musicId;
 
208
        unsigned short max;
 
209
        PianoSearchResult_t searchResult;
 
210
} PianoRequestDataGetSeedSuggestions_t;
 
211
 
 
212
typedef enum {
 
213
        PIANO_RET_ERR = 0,
 
214
        PIANO_RET_OK = 1,
 
215
        PIANO_RET_XML_INVALID = 2,
 
216
        PIANO_RET_AUTH_TOKEN_INVALID = 3,
 
217
        PIANO_RET_AUTH_USER_PASSWORD_INVALID = 4,
 
218
        PIANO_RET_CONTINUE_REQUEST = 5,
 
219
        PIANO_RET_NOT_AUTHORIZED = 6,
 
220
        PIANO_RET_PROTOCOL_INCOMPATIBLE = 7,
 
221
        PIANO_RET_READONLY_MODE = 8,
 
222
        PIANO_RET_STATION_CODE_INVALID = 9,
 
223
        PIANO_RET_IP_REJECTED = 10,
 
224
        PIANO_RET_STATION_NONEXISTENT = 11,
 
225
        PIANO_RET_OUT_OF_MEMORY = 12,
 
226
        PIANO_RET_OUT_OF_SYNC = 13,
 
227
        PIANO_RET_PLAYLIST_END = 14,
 
228
        PIANO_RET_QUICKMIX_NOT_PLAYABLE = 15,
 
229
} PianoReturn_t;
 
230
 
 
231
void PianoInit (PianoHandle_t *);
 
232
void PianoDestroy (PianoHandle_t *);
 
233
void PianoDestroyPlaylist (PianoSong_t *);
 
234
void PianoDestroySearchResult (PianoSearchResult_t *);
 
235
 
 
236
PianoReturn_t PianoRequest (PianoHandle_t *, PianoRequest_t *,
 
237
                PianoRequestType_t);
 
238
PianoReturn_t PianoResponse (PianoHandle_t *, PianoRequest_t *);
 
239
void PianoDestroyRequest (PianoRequest_t *);
 
240
 
 
241
PianoStation_t *PianoFindStationById (PianoStation_t *, const char *);
 
242
const char *PianoErrorToStr (PianoReturn_t);
 
243
 
 
244
#endif /* _PIANO_H */