2
Copyright (c) 2008-2010
3
Lars-Dominik Braun <PromyLOPh@lavabit.com>
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 {
74
PianoSongRating_t rating;
75
PianoAudioFormat_t audioFormat;
77
unsigned int songType;
78
struct PianoSong *next;
81
/* currently only used for search results */
82
typedef struct PianoArtist {
86
struct PianoArtist *next;
89
typedef struct PianoGenre {
92
struct PianoGenre *next;
95
typedef struct PianoGenreCategory {
98
struct PianoGenreCategory *next;
99
} PianoGenreCategory_t;
101
typedef struct PianoHandle {
103
PianoUserInfo_t user;
105
PianoStation_t *stations;
106
PianoGenreCategory_t *genreStations;
110
typedef struct PianoSearchResult {
112
PianoArtist_t *artists;
113
} PianoSearchResult_t;
116
/* 0 is reserved: memset (x, 0, sizeof (x)) */
117
PIANO_REQUEST_LOGIN = 1,
118
PIANO_REQUEST_GET_STATIONS = 2,
119
PIANO_REQUEST_GET_PLAYLIST = 3,
120
PIANO_REQUEST_RATE_SONG = 4,
121
PIANO_REQUEST_ADD_FEEDBACK = 5,
122
PIANO_REQUEST_MOVE_SONG = 6,
123
PIANO_REQUEST_RENAME_STATION = 7,
124
PIANO_REQUEST_DELETE_STATION = 8,
125
PIANO_REQUEST_SEARCH = 9,
126
PIANO_REQUEST_CREATE_STATION = 10,
127
PIANO_REQUEST_ADD_SEED = 11,
128
PIANO_REQUEST_ADD_TIRED_SONG = 12,
129
PIANO_REQUEST_SET_QUICKMIX = 13,
130
PIANO_REQUEST_GET_GENRE_STATIONS = 14,
131
PIANO_REQUEST_TRANSFORM_STATION = 15,
132
PIANO_REQUEST_EXPLAIN = 16,
133
PIANO_REQUEST_GET_SEED_SUGGESTIONS = 17,
134
PIANO_REQUEST_BOOKMARK_SONG = 18,
135
PIANO_REQUEST_BOOKMARK_ARTIST = 19,
136
} PianoRequestType_t;
138
typedef struct PianoRequest {
139
PianoRequestType_t type;
146
/* request data structures */
151
} PianoRequestDataLogin_t;
154
PianoStation_t *station;
155
PianoAudioFormat_t format;
156
PianoSong_t *retPlaylist;
157
} PianoRequestDataGetPlaylist_t;
161
PianoSongRating_t rating;
162
} PianoRequestDataRateSong_t;
168
PianoSongRating_t rating;
169
unsigned int testStrategy;
170
unsigned int songType;
171
} PianoRequestDataAddFeedback_t;
175
PianoStation_t *from;
178
} PianoRequestDataMoveSong_t;
181
PianoStation_t *station;
183
} PianoRequestDataRenameStation_t;
187
PianoSearchResult_t searchResult;
188
} PianoRequestDataSearch_t;
193
} PianoRequestDataCreateStation_t;
196
PianoStation_t *station;
198
} PianoRequestDataAddSeed_t;
203
} PianoRequestDataExplain_t;
208
PianoSearchResult_t searchResult;
209
} PianoRequestDataGetSeedSuggestions_t;
214
PIANO_RET_XML_INVALID = 2,
215
PIANO_RET_AUTH_TOKEN_INVALID = 3,
216
PIANO_RET_AUTH_USER_PASSWORD_INVALID = 4,
217
PIANO_RET_CONTINUE_REQUEST = 5,
218
PIANO_RET_NOT_AUTHORIZED = 6,
219
PIANO_RET_PROTOCOL_INCOMPATIBLE = 7,
220
PIANO_RET_READONLY_MODE = 8,
221
PIANO_RET_STATION_CODE_INVALID = 9,
222
PIANO_RET_IP_REJECTED = 10,
223
PIANO_RET_STATION_NONEXISTENT = 11,
224
PIANO_RET_OUT_OF_MEMORY = 12,
225
PIANO_RET_OUT_OF_SYNC = 13,
226
PIANO_RET_PLAYLIST_END = 14,
227
PIANO_RET_QUICKMIX_NOT_PLAYABLE = 15,
230
void PianoInit (PianoHandle_t *);
231
void PianoDestroy (PianoHandle_t *);
232
void PianoDestroyPlaylist (PianoSong_t *);
233
void PianoDestroySearchResult (PianoSearchResult_t *);
235
PianoReturn_t PianoRequest (PianoHandle_t *, PianoRequest_t *,
237
PianoReturn_t PianoResponse (PianoHandle_t *, PianoRequest_t *);
238
void PianoDestroyRequest (PianoRequest_t *);
240
PianoStation_t *PianoFindStationById (PianoStation_t *, const char *);
241
const char *PianoErrorToStr (PianoReturn_t);
243
#endif /* _PIANO_H */