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

« back to all changes in this revision

Viewing changes to libpiano/src/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 <PromyLOPh@lavabit.com>
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 *musicId;
72
 
        char *title;
73
 
        float fileGain;
74
 
        PianoSongRating_t rating;
75
 
        PianoAudioFormat_t audioFormat;
76
 
        int testStrategy;
77
 
        unsigned int songType;
78
 
        struct PianoSong *next;
79
 
} PianoSong_t;
80
 
 
81
 
/* currently only used for search results */
82
 
typedef struct PianoArtist {
83
 
        char *name;
84
 
        char *musicId;
85
 
        int score;
86
 
        struct PianoArtist *next;
87
 
} PianoArtist_t;
88
 
 
89
 
typedef struct PianoGenre {
90
 
        char *name;
91
 
        char *musicId;
92
 
        struct PianoGenre *next;
93
 
} PianoGenre_t;
94
 
 
95
 
typedef struct PianoGenreCategory {
96
 
        char *name;
97
 
        PianoGenre_t *genres;
98
 
        struct PianoGenreCategory *next;
99
 
} PianoGenreCategory_t;
100
 
 
101
 
typedef struct PianoHandle {
102
 
        char routeId[9];
103
 
        PianoUserInfo_t user;
104
 
        /* linked lists */
105
 
        PianoStation_t *stations;
106
 
        PianoGenreCategory_t *genreStations;
107
 
        int timeOffset;
108
 
} PianoHandle_t;
109
 
 
110
 
typedef struct PianoSearchResult {
111
 
        PianoSong_t *songs;
112
 
        PianoArtist_t *artists;
113
 
} PianoSearchResult_t;
114
 
 
115
 
typedef enum {
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;
137
 
 
138
 
typedef struct PianoRequest {
139
 
        PianoRequestType_t type;
140
 
        void *data;
141
 
        char urlPath[1024];
142
 
        char *postData;
143
 
        char *responseData;
144
 
} PianoRequest_t;
145
 
 
146
 
/* request data structures */
147
 
typedef struct {
148
 
        char *user;
149
 
        char *password;
150
 
        unsigned char step;
151
 
} PianoRequestDataLogin_t;
152
 
 
153
 
typedef struct {
154
 
        PianoStation_t *station;
155
 
        PianoAudioFormat_t format;
156
 
        PianoSong_t *retPlaylist;
157
 
} PianoRequestDataGetPlaylist_t;
158
 
 
159
 
typedef struct {
160
 
        PianoSong_t *song;
161
 
        PianoSongRating_t rating;
162
 
} PianoRequestDataRateSong_t;
163
 
 
164
 
typedef struct {
165
 
        char *stationId;
166
 
        char *musicId;
167
 
        char *userSeed;
168
 
        PianoSongRating_t rating;
169
 
        unsigned int testStrategy;
170
 
        unsigned int songType;
171
 
} PianoRequestDataAddFeedback_t;
172
 
 
173
 
typedef struct {
174
 
        PianoSong_t *song;
175
 
        PianoStation_t *from;
176
 
        PianoStation_t *to;
177
 
        unsigned short step;
178
 
} PianoRequestDataMoveSong_t;
179
 
 
180
 
typedef struct {
181
 
        PianoStation_t *station;
182
 
        char *newName;
183
 
} PianoRequestDataRenameStation_t;
184
 
 
185
 
typedef struct {
186
 
        char *searchStr;
187
 
        PianoSearchResult_t searchResult;
188
 
} PianoRequestDataSearch_t;
189
 
 
190
 
typedef struct {
191
 
        char *type;
192
 
        char *id;
193
 
} PianoRequestDataCreateStation_t;
194
 
 
195
 
typedef struct {
196
 
        PianoStation_t *station;
197
 
        char *musicId;
198
 
} PianoRequestDataAddSeed_t;
199
 
 
200
 
typedef struct {
201
 
        PianoSong_t *song;
202
 
        char *retExplain;
203
 
} PianoRequestDataExplain_t;
204
 
 
205
 
typedef struct {
206
 
        char *musicId;
207
 
        unsigned short max;
208
 
        PianoSearchResult_t searchResult;
209
 
} PianoRequestDataGetSeedSuggestions_t;
210
 
 
211
 
typedef enum {
212
 
        PIANO_RET_ERR = 0,
213
 
        PIANO_RET_OK = 1,
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,
228
 
} PianoReturn_t;
229
 
 
230
 
void PianoInit (PianoHandle_t *);
231
 
void PianoDestroy (PianoHandle_t *);
232
 
void PianoDestroyPlaylist (PianoSong_t *);
233
 
void PianoDestroySearchResult (PianoSearchResult_t *);
234
 
 
235
 
PianoReturn_t PianoRequest (PianoHandle_t *, PianoRequest_t *,
236
 
                PianoRequestType_t);
237
 
PianoReturn_t PianoResponse (PianoHandle_t *, PianoRequest_t *);
238
 
void PianoDestroyRequest (PianoRequest_t *);
239
 
 
240
 
PianoStation_t *PianoFindStationById (PianoStation_t *, const char *);
241
 
const char *PianoErrorToStr (PianoReturn_t);
242
 
 
243
 
#endif /* _PIANO_H */