2
Copyright (c) 2008-2010
3
Lars-Dominik Braun <lars@6xq.net>
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:
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
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
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 :) */
32
#define PIANO_RPC_HOST "www.pandora.com"
33
#define PIANO_RPC_PORT "80"
35
typedef struct PianoUserInfo {
41
typedef struct PianoStation {
44
char useQuickMix; /* station will be included in quickmix */
47
struct PianoStation *next;
56
/* UNKNOWN should be 0, because memset sets audio format to 0 */
64
typedef struct PianoSong {
75
PianoSongRating_t rating;
76
PianoAudioFormat_t audioFormat;
78
unsigned int songType;
79
struct PianoSong *next;
82
/* currently only used for search results */
83
typedef struct PianoArtist {
87
struct PianoArtist *next;
90
typedef struct PianoGenre {
93
struct PianoGenre *next;
96
typedef struct PianoGenreCategory {
99
struct PianoGenreCategory *next;
100
} PianoGenreCategory_t;
102
typedef struct PianoHandle {
104
PianoUserInfo_t user;
106
PianoStation_t *stations;
107
PianoGenreCategory_t *genreStations;
111
typedef struct PianoSearchResult {
113
PianoArtist_t *artists;
114
} PianoSearchResult_t;
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;
139
typedef struct PianoRequest {
140
PianoRequestType_t type;
147
/* request data structures */
152
} PianoRequestDataLogin_t;
155
PianoStation_t *station;
156
PianoAudioFormat_t format;
157
PianoSong_t *retPlaylist;
158
} PianoRequestDataGetPlaylist_t;
162
PianoSongRating_t rating;
163
} PianoRequestDataRateSong_t;
169
PianoSongRating_t rating;
170
unsigned int testStrategy;
171
unsigned int songType;
172
} PianoRequestDataAddFeedback_t;
176
PianoStation_t *from;
179
} PianoRequestDataMoveSong_t;
182
PianoStation_t *station;
184
} PianoRequestDataRenameStation_t;
188
PianoSearchResult_t searchResult;
189
} PianoRequestDataSearch_t;
194
} PianoRequestDataCreateStation_t;
197
PianoStation_t *station;
199
} PianoRequestDataAddSeed_t;
204
} PianoRequestDataExplain_t;
209
PianoSearchResult_t searchResult;
210
} PianoRequestDataGetSeedSuggestions_t;
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,
231
void PianoInit (PianoHandle_t *);
232
void PianoDestroy (PianoHandle_t *);
233
void PianoDestroyPlaylist (PianoSong_t *);
234
void PianoDestroySearchResult (PianoSearchResult_t *);
236
PianoReturn_t PianoRequest (PianoHandle_t *, PianoRequest_t *,
238
PianoReturn_t PianoResponse (PianoHandle_t *, PianoRequest_t *);
239
void PianoDestroyRequest (PianoRequest_t *);
241
PianoStation_t *PianoFindStationById (PianoStation_t *, const char *);
242
const char *PianoErrorToStr (PianoReturn_t);
244
#endif /* _PIANO_H */