~ubuntu-branches/ubuntu/maverick/pianobar/maverick

« back to all changes in this revision

Viewing changes to src/ui_act.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Faraone
  • Date: 2010-10-07 09:15:49 UTC
  • mfrom: (1.3.1 upstream) (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20101007091549-sscxdr1kud0d4hyl
Tags: 2010.10.07-1
* New upstream version. 
  - XMLRPC api version bump (v28) (closes: #599338)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "ui_act.h"
32
32
#include "ui_readline.h"
33
33
 
34
 
#define RETURN_IF_NO_STATION if (*curStation == NULL) { \
 
34
#define RETURN_IF_NO_STATION if (app->curStation == NULL) { \
35
35
                BarUiMsg (MSG_ERR, "No station selected.\n"); \
36
36
                return; }
37
37
 
38
 
#define RETURN_IF_NO_SONG if (*curStation == NULL || *curSong == NULL) { \
 
38
#define RETURN_IF_NO_SONG if (app->curStation == NULL || app->playlist == NULL) { \
39
39
                BarUiMsg (MSG_ERR, "No song playing.\n"); \
40
40
                return; }
41
41
 
 
42
/*      standard eventcmd call
 
43
 */
 
44
#define BarUiActDefaultEventcmd(name) BarUiStartEventCmd (&app->settings, \
 
45
                name, app->curStation, app->playlist, &app->player, pRet, wRet)
 
46
 
 
47
/*      standard piano call
 
48
 */
 
49
#define BarUiActDefaultPianoCall(call, arg) BarUiPianoCall (&app->ph, \
 
50
                call, &app->waith, arg, &pRet, &wRet)
 
51
 
42
52
/*      helper to _really_ skip a song (unlock mutex, quit player)
43
53
 *      @param player handle
44
54
 */
70
80
 
71
81
/*      print current shortcut configuration
72
82
 */
73
 
void BarUiActHelp (BAR_KS_ARGS) {
74
 
        const char *idToDesc[] = {
 
83
BarUiActCallback(BarUiActHelp) {
 
84
        static const char *idToDesc[] = {
75
85
                        NULL,
76
86
                        "love current song",
77
87
                        "ban current song",
100
110
        BarUiMsg (MSG_NONE, "\r");
101
111
        for (i = 0; i < BAR_KS_COUNT; i++) {
102
112
                if (idToDesc[i] != NULL) {
103
 
                        BarUiMsg (MSG_LIST, "%c    %s\n", settings->keys[i], idToDesc[i]);
 
113
                        BarUiMsg (MSG_LIST, "%c    %s\n", app->settings.keys[i], idToDesc[i]);
104
114
                }
105
115
        }
106
116
}
107
117
 
108
118
/*      add more music to current station
109
119
 */
110
 
void BarUiActAddMusic (BAR_KS_ARGS) {
 
120
BarUiActCallback(BarUiActAddMusic) {
111
121
        PianoReturn_t pRet;
112
122
        WaitressReturn_t wRet;
113
123
        PianoRequestDataAddSeed_t reqData;
114
124
 
115
125
        RETURN_IF_NO_STATION;
116
126
 
117
 
        reqData.musicId = BarUiSelectMusicId (ph, waith, curFd, (*curSong)->musicId);
 
127
        reqData.musicId = BarUiSelectMusicId (&app->ph, &app->waith, curFd,
 
128
                        app->playlist->musicId);
118
129
        if (reqData.musicId != NULL) {
119
 
                if (!BarTransformIfShared (ph, waith, *curStation)) {
 
130
                if (!BarTransformIfShared (&app->ph, &app->waith, app->curStation)) {
120
131
                        return;
121
132
                }
122
 
                reqData.station = *curStation;
 
133
                reqData.station = app->curStation;
123
134
 
124
135
                BarUiMsg (MSG_INFO, "Adding music to station... ");
125
 
                BarUiPianoCall (ph, PIANO_REQUEST_ADD_SEED, waith, &reqData, &pRet,
126
 
                                &wRet);
 
136
                BarUiActDefaultPianoCall (PIANO_REQUEST_ADD_SEED, &reqData);
127
137
 
128
138
                free (reqData.musicId);
129
139
 
130
 
                BarUiStartEventCmd (settings, "stationaddmusic", *curStation, *curSong,
131
 
                                player, pRet, wRet);
 
140
                BarUiActDefaultEventcmd ("stationaddmusic");
132
141
        }
133
142
}
134
143
 
135
144
/*      ban song
136
145
 */
137
 
void BarUiActBanSong (BAR_KS_ARGS) {
 
146
BarUiActCallback(BarUiActBanSong) {
138
147
        PianoReturn_t pRet;
139
148
        WaitressReturn_t wRet;
140
149
 
141
150
        RETURN_IF_NO_SONG;
142
151
 
143
 
        if (!BarTransformIfShared (ph, waith, *curStation)) {
 
152
        if (!BarTransformIfShared (&app->ph, &app->waith, app->curStation)) {
144
153
                return;
145
154
        }
146
155
 
147
156
        PianoRequestDataRateSong_t reqData;
148
 
        reqData.song = *curSong;
 
157
        reqData.song = app->playlist;
149
158
        reqData.rating = PIANO_RATE_BAN;
150
159
 
151
160
        BarUiMsg (MSG_INFO, "Banning song... ");
152
 
        if (BarUiPianoCall (ph, PIANO_REQUEST_RATE_SONG, waith, &reqData, &pRet,
153
 
                        &wRet)) {
154
 
                BarUiDoSkipSong (player);
 
161
        if (BarUiActDefaultPianoCall (PIANO_REQUEST_RATE_SONG, &reqData)) {
 
162
                BarUiDoSkipSong (&app->player);
155
163
        }
156
 
        BarUiStartEventCmd (settings, "songban", *curStation, *curSong, player,
157
 
                        pRet, wRet);
 
164
        BarUiActDefaultEventcmd ("songban");
158
165
}
159
166
 
160
167
/*      create new station
161
168
 */
162
 
void BarUiActCreateStation (BAR_KS_ARGS) {
 
169
BarUiActCallback(BarUiActCreateStation) {
163
170
        PianoReturn_t pRet;
164
171
        WaitressReturn_t wRet;
165
172
        PianoRequestDataCreateStation_t reqData;
166
173
 
167
 
        reqData.id = BarUiSelectMusicId (ph, waith, curFd, NULL);
 
174
        reqData.id = BarUiSelectMusicId (&app->ph, &app->waith, curFd, NULL);
168
175
        if (reqData.id != NULL) {
169
176
                reqData.type = "mi";
170
177
                BarUiMsg (MSG_INFO, "Creating station... ");
171
 
                BarUiPianoCall (ph, PIANO_REQUEST_CREATE_STATION, waith, &reqData,
172
 
                                &pRet, &wRet);
 
178
                BarUiActDefaultPianoCall (PIANO_REQUEST_CREATE_STATION, &reqData);
173
179
                free (reqData.id);
174
 
                BarUiStartEventCmd (settings, "stationcreate", *curStation, *curSong,
175
 
                                player, pRet, wRet);
 
180
                BarUiActDefaultEventcmd ("stationcreate");
176
181
        }
177
182
}
178
183
 
179
184
/*      add shared station by id
180
185
 */
181
 
void BarUiActAddSharedStation (BAR_KS_ARGS) {
 
186
BarUiActCallback(BarUiActAddSharedStation) {
182
187
        PianoReturn_t pRet;
183
188
        WaitressReturn_t wRet;
184
189
        PianoRequestDataCreateStation_t reqData;
190
195
                reqData.id = stationId;
191
196
                reqData.type = "sh";
192
197
                BarUiMsg (MSG_INFO, "Adding shared station... ");
193
 
                BarUiPianoCall (ph, PIANO_REQUEST_CREATE_STATION, waith, &reqData,
194
 
                                &pRet, &wRet);
195
 
                BarUiStartEventCmd (settings, "stationaddshared", *curStation,
196
 
                                *curSong, player, pRet, wRet);
 
198
                BarUiActDefaultPianoCall (PIANO_REQUEST_CREATE_STATION, &reqData);
 
199
                BarUiActDefaultEventcmd ("stationaddshared");
197
200
        }
198
201
}
199
202
 
200
203
/*      delete current station
201
204
 */
202
 
void BarUiActDeleteStation (BAR_KS_ARGS) {
 
205
BarUiActCallback(BarUiActDeleteStation) {
203
206
        PianoReturn_t pRet;
204
207
        WaitressReturn_t wRet;
205
208
 
206
209
        RETURN_IF_NO_STATION;
207
210
 
208
211
        BarUiMsg (MSG_QUESTION, "Really delete \"%s\"? [yN] ",
209
 
                        (*curStation)->name);
 
212
                        app->curStation->name);
210
213
        if (BarReadlineYesNo (0, curFd)) {
211
214
                BarUiMsg (MSG_INFO, "Deleting station... ");
212
 
                if (BarUiPianoCall (ph, PIANO_REQUEST_DELETE_STATION, waith,
213
 
                                *curStation, &pRet, &wRet)) {
214
 
                        BarUiDoSkipSong (player);
215
 
                        PianoDestroyPlaylist (*curSong);
216
 
                        *curSong = NULL;
217
 
                        *curStation = NULL;
 
215
                if (BarUiActDefaultPianoCall (PIANO_REQUEST_DELETE_STATION,
 
216
                                app->curStation)) {
 
217
                        BarUiDoSkipSong (&app->player);
 
218
                        PianoDestroyPlaylist (app->playlist);
 
219
                        app->playlist = NULL;
 
220
                        app->curStation = NULL;
218
221
                }
219
 
                BarUiStartEventCmd (settings, "stationdelete", *curStation, *curSong,
220
 
                                player, pRet, wRet);
 
222
                BarUiActDefaultEventcmd ("stationdelete");
221
223
        }
222
224
}
223
225
 
224
226
/*      explain pandora's song choice
225
227
 */
226
 
void BarUiActExplain (BAR_KS_ARGS) {
 
228
BarUiActCallback(BarUiActExplain) {
227
229
        PianoReturn_t pRet;
228
230
        WaitressReturn_t wRet;
229
231
        PianoRequestDataExplain_t reqData;
230
232
 
231
233
        RETURN_IF_NO_STATION;
232
234
 
233
 
        reqData.song = *curSong;
 
235
        reqData.song = app->playlist;
234
236
 
235
237
        BarUiMsg (MSG_INFO, "Receiving explanation... ");
236
 
        if (BarUiPianoCall (ph, PIANO_REQUEST_EXPLAIN, waith, &reqData, &pRet,
237
 
                        &wRet)) {
 
238
        if (BarUiActDefaultPianoCall (PIANO_REQUEST_EXPLAIN, &reqData)) {
238
239
                BarUiMsg (MSG_INFO, "%s\n", reqData.retExplain);
239
240
                free (reqData.retExplain);
240
241
        }
241
 
        BarUiStartEventCmd (settings, "songexplain", *curStation, *curSong, player,
242
 
                        pRet, wRet);
 
242
        BarUiActDefaultEventcmd ("songexplain");
243
243
}
244
244
 
245
245
/*      choose genre station and add it as shared station
246
246
 */
247
 
void BarUiActStationFromGenre (BAR_KS_ARGS) {
 
247
BarUiActCallback(BarUiActStationFromGenre) {
248
248
        /* use genre station */
249
 
        BarStationFromGenre (ph, waith, curFd);
 
249
        BarStationFromGenre (&app->ph, &app->waith, curFd);
250
250
}
251
251
 
252
252
/*      print verbose song information
253
253
 */
254
 
void BarUiActSongInfo (BAR_KS_ARGS) {
 
254
BarUiActCallback(BarUiActSongInfo) {
255
255
        RETURN_IF_NO_SONG;
256
256
 
257
 
        BarUiPrintStation ((*curStation));
 
257
        BarUiPrintStation (app->curStation);
258
258
        /* print real station if quickmix */
259
 
        BarUiPrintSong ((*curSong), (*curStation)->isQuickMix ?
260
 
                        PianoFindStationById (ph->stations, (*curSong)->stationId) : NULL);
 
259
        BarUiPrintSong (app->playlist, app->curStation->isQuickMix ?
 
260
                        PianoFindStationById (app->ph.stations, app->playlist->stationId) :
 
261
                        NULL);
261
262
}
262
263
 
263
264
/*      print some debugging information
264
265
 */
265
 
void BarUiActDebug (BAR_KS_ARGS) {
 
266
BarUiActCallback(BarUiActDebug) {
266
267
        RETURN_IF_NO_SONG;
267
268
 
268
269
        /* print debug-alike infos */
272
273
                        "audioFormat:\t%i\n"
273
274
                        "audioUrl:\t%s\n"
274
275
                        "fileGain:\t%f\n"
275
 
                        "focusTraitId:\t%s\n"
276
276
                        "identity:\t%s\n"
277
 
                        "matchingSeed:\t%s\n"
278
277
                        "musicId:\t%s\n"
279
278
                        "rating:\t%i\n"
 
279
                        "songType:\t%i\n"
280
280
                        "stationId:\t%s\n"
 
281
                        "testStrategy:\t%i\n"
281
282
                        "title:\t%s\n"
282
283
                        "userSeed:\t%s\n",
283
 
                        (*curSong)->album, (*curSong)->artist, (*curSong)->audioFormat,
284
 
                        (*curSong)->audioUrl, (*curSong)->fileGain,
285
 
                        (*curSong)->focusTraitId, (*curSong)->identity,
286
 
                        (*curSong)->matchingSeed, (*curSong)->musicId, (*curSong)->rating,
287
 
                        (*curSong)->stationId, (*curSong)->title, (*curSong)->userSeed);
 
284
                        app->playlist->album, app->playlist->artist,
 
285
                        app->playlist->audioFormat, app->playlist->audioUrl,
 
286
                        app->playlist->fileGain, app->playlist->identity,
 
287
                        app->playlist->musicId, app->playlist->rating,
 
288
                        app->playlist->songType, app->playlist->stationId,
 
289
                        app->playlist->testStrategy, app->playlist->title,
 
290
                        app->playlist->userSeed);
288
291
}
289
292
 
290
293
/*      rate current song
291
294
 */
292
 
void BarUiActLoveSong (BAR_KS_ARGS) {
 
295
BarUiActCallback(BarUiActLoveSong) {
293
296
        PianoReturn_t pRet;
294
297
        WaitressReturn_t wRet;
295
298
 
296
299
        RETURN_IF_NO_SONG;
297
300
 
298
 
        if (!BarTransformIfShared (ph, waith, *curStation)) {
 
301
        if (!BarTransformIfShared (&app->ph, &app->waith, app->curStation)) {
299
302
                return;
300
303
        }
301
304
 
302
305
        PianoRequestDataRateSong_t reqData;
303
 
        reqData.song = *curSong;
 
306
        reqData.song = app->playlist;
304
307
        reqData.rating = PIANO_RATE_LOVE;
305
308
 
306
309
        BarUiMsg (MSG_INFO, "Loving song... ");
307
 
        BarUiPianoCall (ph, PIANO_REQUEST_RATE_SONG, waith, &reqData, &pRet,
308
 
                        &wRet);
309
 
        BarUiStartEventCmd (settings, "songlove", *curStation, *curSong, player,
310
 
                        pRet, wRet);
 
310
        BarUiActDefaultPianoCall (PIANO_REQUEST_RATE_SONG, &reqData);
 
311
        BarUiActDefaultEventcmd ("songlove");
311
312
}
312
313
 
313
314
/*      skip song
314
315
 */
315
 
void BarUiActSkipSong (BAR_KS_ARGS) {
316
 
        BarUiDoSkipSong (player);
 
316
BarUiActCallback(BarUiActSkipSong) {
 
317
        BarUiDoSkipSong (&app->player);
317
318
}
318
319
 
319
320
/*      move song to different station
320
321
 */
321
 
void BarUiActMoveSong (BAR_KS_ARGS) {
 
322
BarUiActCallback(BarUiActMoveSong) {
322
323
        PianoReturn_t pRet;
323
324
        WaitressReturn_t wRet;
324
325
        PianoRequestDataMoveSong_t reqData;
327
328
 
328
329
        RETURN_IF_NO_SONG;
329
330
 
330
 
        reqData.to = BarUiSelectStation (ph, "Move song to station: ", curFd);
 
331
        reqData.to = BarUiSelectStation (&app->ph, "Move song to station: ",
 
332
                        app->settings.sortOrder, curFd);
331
333
        if (reqData.to != NULL) {
332
334
                /* find original station (just is case we're playing a quickmix
333
335
                 * station) */
334
 
                reqData.from = PianoFindStationById (ph->stations, (*curSong)->stationId);
 
336
                reqData.from = PianoFindStationById (app->ph.stations,
 
337
                                app->playlist->stationId);
335
338
                if (reqData.from == NULL) {
336
339
                        BarUiMsg (MSG_ERR, "Station not found\n");
337
340
                        return;
338
341
                }
339
342
 
340
 
                if (!BarTransformIfShared (ph, waith, reqData.from) ||
341
 
                                !BarTransformIfShared (ph, waith, reqData.to)) {
 
343
                if (!BarTransformIfShared (&app->ph, &app->waith, reqData.from) ||
 
344
                                !BarTransformIfShared (&app->ph, &app->waith, reqData.to)) {
342
345
                        return;
343
346
                }
344
347
                BarUiMsg (MSG_INFO, "Moving song to \"%s\"... ", reqData.to->name);
345
 
                reqData.song = *curSong;
346
 
                if (BarUiPianoCall (ph, PIANO_REQUEST_MOVE_SONG, waith, &reqData,
347
 
                                &pRet, &wRet)) {
348
 
                        BarUiDoSkipSong (player);
 
348
                reqData.song = app->playlist;
 
349
                if (BarUiActDefaultPianoCall (PIANO_REQUEST_MOVE_SONG, &reqData)) {
 
350
                        BarUiDoSkipSong (&app->player);
349
351
                }
350
 
                BarUiStartEventCmd (settings, "songmove", *curStation, *curSong,
351
 
                                player, pRet, wRet);
 
352
                BarUiActDefaultEventcmd ("songmove");
352
353
        }
353
354
}
354
355
 
355
356
/*      pause
356
357
 */
357
 
void BarUiActPause (BAR_KS_ARGS) {
 
358
BarUiActCallback(BarUiActPause) {
358
359
        /* already locked => unlock/unpause */
359
 
        if (pthread_mutex_trylock (&player->pauseMutex) == EBUSY) {
360
 
                pthread_mutex_unlock (&player->pauseMutex);
 
360
        if (pthread_mutex_trylock (&app->player.pauseMutex) == EBUSY) {
 
361
                pthread_mutex_unlock (&app->player.pauseMutex);
361
362
        }
362
363
}
363
364
 
364
365
/*      rename current station
365
366
 */
366
 
void BarUiActRenameStation (BAR_KS_ARGS) {
 
367
BarUiActCallback(BarUiActRenameStation) {
367
368
        PianoReturn_t pRet;
368
369
        WaitressReturn_t wRet;
369
370
        char lineBuf[100];
373
374
        BarUiMsg (MSG_QUESTION, "New name: ");
374
375
        if (BarReadlineStr (lineBuf, sizeof (lineBuf), 0, curFd) > 0) {
375
376
                PianoRequestDataRenameStation_t reqData;
376
 
                if (!BarTransformIfShared (ph, waith, *curStation)) {
 
377
                if (!BarTransformIfShared (&app->ph, &app->waith, app->curStation)) {
377
378
                        return;
378
379
                }
379
380
 
380
 
                reqData.station = *curStation;
 
381
                reqData.station = app->curStation;
381
382
                reqData.newName = lineBuf;
382
383
 
383
384
                BarUiMsg (MSG_INFO, "Renaming station... ");
384
 
                BarUiPianoCall (ph, PIANO_REQUEST_RENAME_STATION, waith, &reqData,
385
 
                                &pRet, &wRet);
386
 
                BarUiStartEventCmd (settings, "stationrename", *curStation, *curSong,
387
 
                                player, pRet, wRet);
 
385
                BarUiActDefaultPianoCall (PIANO_REQUEST_RENAME_STATION, &reqData);
 
386
                BarUiActDefaultEventcmd ("stationrename");
388
387
        }
389
388
}
390
389
 
391
390
/*      play another station
392
391
 */
393
 
void BarUiActSelectStation (BAR_KS_ARGS) {
394
 
        PianoStation_t *newStation = BarUiSelectStation (ph, "Select station: ",
395
 
                        curFd);
 
392
BarUiActCallback(BarUiActSelectStation) {
 
393
        PianoStation_t *newStation = BarUiSelectStation (&app->ph, "Select station: ",
 
394
                        app->settings.sortOrder, curFd);
396
395
        if (newStation != NULL) {
397
 
                *curStation = newStation;
398
 
                BarUiPrintStation ((*curStation));
399
 
                BarUiDoSkipSong (player);
400
 
                PianoDestroyPlaylist (*curSong);
401
 
                *curSong = NULL;
 
396
                app->curStation = newStation;
 
397
                BarUiPrintStation (app->curStation);
 
398
                BarUiDoSkipSong (&app->player);
 
399
                PianoDestroyPlaylist (app->playlist);
 
400
                app->playlist = NULL;
402
401
        }
403
402
}
404
403
 
405
404
/*      ban song for 1 month
406
405
 */
407
 
void BarUiActTempBanSong (BAR_KS_ARGS) {
 
406
BarUiActCallback(BarUiActTempBanSong) {
408
407
        PianoReturn_t pRet;
409
408
        WaitressReturn_t wRet;
410
409
 
411
410
        RETURN_IF_NO_SONG;
412
411
 
413
412
        BarUiMsg (MSG_INFO, "Putting song on shelf... ");
414
 
        if (BarUiPianoCall (ph, PIANO_REQUEST_ADD_TIRED_SONG, waith, *curSong,
415
 
                        &pRet, &wRet)) {
416
 
                BarUiDoSkipSong (player);
 
413
        if (BarUiActDefaultPianoCall (PIANO_REQUEST_ADD_TIRED_SONG, app->playlist)) {
 
414
                BarUiDoSkipSong (&app->player);
417
415
        }
418
 
        BarUiStartEventCmd (settings, "songshelf", *curStation, *curSong, player,
419
 
                        pRet, wRet);
 
416
        BarUiActDefaultEventcmd ("songshelf");
420
417
}
421
418
 
422
419
/*      print upcoming songs
423
420
 */
424
 
void BarUiActPrintUpcoming (BAR_KS_ARGS) {
 
421
BarUiActCallback(BarUiActPrintUpcoming) {
425
422
        RETURN_IF_NO_SONG;
426
423
 
427
 
        PianoSong_t *nextSong = (*curSong)->next;
 
424
        PianoSong_t *nextSong = app->playlist->next;
428
425
        if (nextSong != NULL) {
429
426
                int i = 0;
430
427
                while (nextSong != NULL) {
441
438
/*      if current station is a quickmix: select stations that are played in
442
439
 *      quickmix
443
440
 */
444
 
void BarUiActSelectQuickMix (BAR_KS_ARGS) {
 
441
BarUiActCallback(BarUiActSelectQuickMix) {
445
442
        PianoReturn_t pRet;
446
443
        WaitressReturn_t wRet;
447
444
 
448
445
        RETURN_IF_NO_STATION;
449
446
 
450
 
        if ((*curStation)->isQuickMix) {
 
447
        if (app->curStation->isQuickMix) {
451
448
                PianoStation_t *selStation;
452
 
                while ((selStation = BarUiSelectStation (ph,
453
 
                                "Toggle quickmix for station: ", curFd)) != NULL) {
 
449
                while ((selStation = BarUiSelectStation (&app->ph,
 
450
                                "Toggle quickmix for station: ", app->settings.sortOrder,
 
451
                                curFd)) != NULL) {
454
452
                        selStation->useQuickMix = !selStation->useQuickMix;
455
453
                }
456
454
                BarUiMsg (MSG_INFO, "Setting quickmix stations... ");
457
 
                BarUiPianoCall (ph, PIANO_REQUEST_SET_QUICKMIX, waith, NULL, &pRet,
458
 
                                &wRet);
459
 
                BarUiStartEventCmd (settings, "stationquickmixtoggle", *curStation,
460
 
                                *curSong, player, pRet, wRet);
 
455
                BarUiActDefaultPianoCall (PIANO_REQUEST_SET_QUICKMIX, NULL);
 
456
                BarUiActDefaultEventcmd ("stationquickmixtoggle");
461
457
        } else {
462
458
                BarUiMsg (MSG_ERR, "Not a QuickMix station.\n");
463
459
        }
465
461
 
466
462
/*      quit
467
463
 */
468
 
void BarUiActQuit (BAR_KS_ARGS) {
469
 
        *doQuit = 1;
470
 
        BarUiDoSkipSong (player);
 
464
BarUiActCallback(BarUiActQuit) {
 
465
        app->doQuit = 1;
 
466
        BarUiDoSkipSong (&app->player);
471
467
}
472
468
 
473
469
/*      song history
474
470
 */
475
 
void BarUiActHistory (BAR_KS_ARGS) {
 
471
BarUiActCallback(BarUiActHistory) {
476
472
        PianoReturn_t pRet;
477
473
        WaitressReturn_t wRet;
478
474
        char selectBuf[2], allowedBuf[3];
479
475
        PianoSong_t *selectedSong;
480
476
 
481
 
        if (*songHistory != NULL) {
482
 
                selectedSong = BarUiSelectSong (*songHistory, curFd);
 
477
        if (app->songHistory != NULL) {
 
478
                selectedSong = BarUiSelectSong (app->songHistory, curFd);
483
479
                if (selectedSong != NULL) {
484
480
                        /* use user-defined keybindings */
485
 
                        allowedBuf[0] = settings->keys[BAR_KS_LOVE];
486
 
                        allowedBuf[1] = settings->keys[BAR_KS_BAN];
 
481
                        allowedBuf[0] = app->settings.keys[BAR_KS_LOVE];
 
482
                        allowedBuf[1] = app->settings.keys[BAR_KS_BAN];
487
483
                        allowedBuf[2] = '\0';
488
484
 
489
485
                        BarUiMsg (MSG_QUESTION, "%s - %s: love[%c] or ban[%c]? ",
490
486
                                        selectedSong->artist, selectedSong->title,
491
 
                                        settings->keys[BAR_KS_LOVE], settings->keys[BAR_KS_BAN]);
 
487
                                        app->settings.keys[BAR_KS_LOVE],
 
488
                                        app->settings.keys[BAR_KS_BAN]);
492
489
                        BarReadline (selectBuf, sizeof (selectBuf), allowedBuf, 1, 0, curFd);
493
490
 
494
 
                        if (selectBuf[0] == settings->keys[BAR_KS_LOVE] ||
495
 
                                        selectBuf[0] == settings->keys[BAR_KS_BAN]) {
 
491
                        if (selectBuf[0] == app->settings.keys[BAR_KS_LOVE] ||
 
492
                                        selectBuf[0] == app->settings.keys[BAR_KS_BAN]) {
496
493
                                /* make sure we're transforming the _original_ station (not
497
494
                                 * curStation) */
498
495
                                PianoStation_t *songStation =
499
 
                                                PianoFindStationById (ph->stations,
 
496
                                                PianoFindStationById (app->ph.stations,
500
497
                                                                selectedSong->stationId);
501
498
 
502
499
                                if (songStation == NULL) {
504
501
                                        return;
505
502
                                }
506
503
 
507
 
                                if (!BarTransformIfShared (ph, waith, songStation)) {
 
504
                                if (!BarTransformIfShared (&app->ph, &app->waith, songStation)) {
508
505
                                        return;
509
506
                                }
510
507
 
511
 
                                if (selectBuf[0] == settings->keys[BAR_KS_LOVE]) {
 
508
                                if (selectBuf[0] == app->settings.keys[BAR_KS_LOVE]) {
512
509
                                        /* FIXME: copy&waste */
513
510
                                        PianoRequestDataRateSong_t reqData;
514
511
                                        reqData.song = selectedSong;
515
512
                                        reqData.rating = PIANO_RATE_LOVE;
516
513
 
517
514
                                        BarUiMsg (MSG_INFO, "Loving song... ");
518
 
                                        BarUiPianoCall (ph, PIANO_REQUEST_RATE_SONG, waith,
519
 
                                                        &reqData, &pRet, &wRet);
 
515
                                        BarUiActDefaultPianoCall (PIANO_REQUEST_RATE_SONG,
 
516
                                                        &reqData);
520
517
 
521
 
                                        BarUiStartEventCmd (settings, "songlove", songStation,
522
 
                                                        selectedSong, player, pRet, wRet);
523
 
                                } else if (selectBuf[0] == settings->keys[BAR_KS_BAN]) {
 
518
                                        BarUiStartEventCmd (&app->settings, "songlove", songStation,
 
519
                                                        selectedSong, &app->player, pRet, wRet);
 
520
                                } else if (selectBuf[0] == app->settings.keys[BAR_KS_BAN]) {
524
521
                                        PianoRequestDataRateSong_t reqData;
525
522
                                        reqData.song = selectedSong;
526
523
                                        reqData.rating = PIANO_RATE_BAN;
527
524
 
528
525
                                        BarUiMsg (MSG_INFO, "Banning song... ");
529
 
                                        BarUiPianoCall (ph, PIANO_REQUEST_RATE_SONG, waith,
530
 
                                                        &reqData, &pRet, &wRet);
531
 
                                        BarUiStartEventCmd (settings, "songban", songStation,
532
 
                                                        selectedSong, player, pRet, wRet);
 
526
                                        BarUiActDefaultPianoCall (PIANO_REQUEST_RATE_SONG,
 
527
                                                        &reqData);
 
528
                                        BarUiStartEventCmd (&app->settings, "songban", songStation,
 
529
                                                        selectedSong, &app->player, pRet, wRet);
533
530
                                } /* end if */
534
531
                        } /* end if selectBuf[0] */
535
532
                } /* end if selectedSong != NULL */
536
533
        } else {
537
 
                BarUiMsg (MSG_INFO, (settings->history == 0) ? "History disabled.\n" :
 
534
                BarUiMsg (MSG_INFO, (app->settings.history == 0) ? "History disabled.\n" :
538
535
                                "No history yet.\n");
539
536
        }
540
537
}
541
538
 
542
539
/*      create song bookmark
543
540
 */
544
 
void BarUiActBookmark (BAR_KS_ARGS) {
 
541
BarUiActCallback(BarUiActBookmark) {
545
542
        PianoReturn_t pRet;
546
543
        WaitressReturn_t wRet;
547
544
        char selectBuf[2];
552
549
        BarReadline (selectBuf, sizeof (selectBuf), "sa", 1, 0, curFd);
553
550
        if (selectBuf[0] == 's') {
554
551
                BarUiMsg (MSG_INFO, "Bookmarking song... ");
555
 
                BarUiPianoCall (ph, PIANO_REQUEST_BOOKMARK_SONG, waith, *curSong,
556
 
                                &pRet, &wRet);
557
 
                BarUiStartEventCmd (settings, "songbookmark", *curStation, *curSong,
558
 
                                player, pRet, wRet);
 
552
                BarUiActDefaultPianoCall (PIANO_REQUEST_BOOKMARK_SONG, app->playlist);
 
553
                BarUiActDefaultEventcmd ("songbookmark");
559
554
        } else if (selectBuf[0] == 'a') {
560
555
                BarUiMsg (MSG_INFO, "Bookmarking artist... ");
561
 
                BarUiPianoCall (ph, PIANO_REQUEST_BOOKMARK_ARTIST, waith, *curSong,
562
 
                                &pRet, &wRet);
563
 
                BarUiStartEventCmd (settings, "artistbookmark", *curStation, *curSong,
564
 
                                player, pRet, wRet);
 
556
                BarUiActDefaultPianoCall (PIANO_REQUEST_BOOKMARK_ARTIST,
 
557
                                app->playlist);
 
558
                BarUiActDefaultEventcmd ("artistbookmark");
565
559
        }
566
560
}
567
561