~ubuntu-branches/ubuntu/trusty/pianobar/trusty

« back to all changes in this revision

Viewing changes to src/main.c

  • Committer: Package Import Robot
  • Author(s): Luke Faraone
  • Date: 2012-05-06 14:24:34 UTC
  • mfrom: (1.3.9)
  • Revision ID: package-import@ubuntu.com-20120506142434-74kwucnyp97msxdi
Tags: 2012.05.06-1
* New upstream version.
  - JSON api support (closes: #670483, LP: #988395)

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
                char passBuf[100];
104
104
                BarUiMsg (settings, MSG_QUESTION, "Password: ");
105
105
                BarReadlineStr (passBuf, sizeof (passBuf), input, BAR_RL_NOECHO);
106
 
                write (STDIN_FILENO, "\n", 1);
 
106
                /* write missing newline */
 
107
                puts ("");
107
108
                settings->password = strdup (passBuf);
108
109
        }
109
110
}
136
137
        }
137
138
        /* no autostart? ask the user */
138
139
        if (app->curStation == NULL) {
139
 
                app->curStation = BarUiSelectStation (app, app->ph.stations, "Select station: ", NULL);
 
140
                app->curStation = BarUiSelectStation (app, app->ph.stations,
 
141
                                "Select station: ", NULL, app->settings.autoselect);
140
142
        }
141
143
        if (app->curStation != NULL) {
142
144
                BarUiPrintStation (&app->settings, app->curStation);
291
293
 
292
294
                /* check whether player finished playing and start playing new
293
295
                 * song */
294
 
                if (app->player.mode >= PLAYER_FINISHED_PLAYBACK ||
295
 
                                app->player.mode == PLAYER_FREED) {
296
 
                        if (app->curStation != NULL) {
297
 
                                /* what's next? */
298
 
                                if (app->playlist != NULL) {
299
 
                                        PianoSong_t *histsong = app->playlist;
300
 
                                        app->playlist = app->playlist->next;
301
 
                                        BarUiHistoryPrepend (app, histsong);
302
 
                                }
303
 
                                if (app->playlist == NULL) {
304
 
                                        BarMainGetPlaylist (app);
305
 
                                }
306
 
                                /* song ready to play */
307
 
                                if (app->playlist != NULL) {
308
 
                                        BarMainStartPlayback (app, &playerThread);
309
 
                                }
 
296
                if (app->player.mode == PLAYER_FREED && app->curStation != NULL) {
 
297
                        /* what's next? */
 
298
                        if (app->playlist != NULL) {
 
299
                                PianoSong_t *histsong = app->playlist;
 
300
                                app->playlist = app->playlist->next;
 
301
                                BarUiHistoryPrepend (app, histsong);
 
302
                        }
 
303
                        if (app->playlist == NULL) {
 
304
                                BarMainGetPlaylist (app);
 
305
                        }
 
306
                        /* song ready to play */
 
307
                        if (app->playlist != NULL) {
 
308
                                BarMainStartPlayback (app, &playerThread);
310
309
                        }
311
310
                }
312
311
 
339
338
        /* init some things */
340
339
        ao_initialize ();
341
340
        gnutls_global_init ();
342
 
        PianoInit (&app.ph);
343
341
 
344
342
        BarSettingsInit (&app.settings);
345
343
        BarSettingsRead (&app.settings);
346
344
 
 
345
        PianoInit (&app.ph, app.settings.partnerUser, app.settings.partnerPassword,
 
346
                        app.settings.device, app.settings.inkey, app.settings.outkey);
 
347
 
347
348
        BarUiMsg (&app.settings, MSG_NONE,
348
349
                        "Welcome to " PACKAGE " (" VERSION ")! ");
349
350
        if (app.settings.keys[BAR_KS_HELP] == BAR_KS_DISABLED) {
356
357
 
357
358
        WaitressInit (&app.waith);
358
359
        app.waith.url.host = strdup (PIANO_RPC_HOST);
359
 
        app.waith.url.tls = true;
360
360
        app.waith.tlsFingerprint = app.settings.tlsFingerprint;
361
361
 
362
362
        /* init fds */
368
368
        assert (sizeof (app.input.fds) / sizeof (*app.input.fds) >= 2);
369
369
        app.input.fds[1] = open (app.settings.fifo, O_RDWR);
370
370
        if (app.input.fds[1] != -1) {
371
 
                FD_SET(app.input.fds[1], &app.input.set);
372
 
                BarUiMsg (&app.settings, MSG_INFO, "Control fifo at %s opened\n",
373
 
                                app.settings.fifo);
 
371
                struct stat s;
 
372
 
 
373
                /* check for file type, must be fifo */
 
374
                fstat (app.input.fds[1], &s);
 
375
                if (!S_ISFIFO (s.st_mode)) {
 
376
                        BarUiMsg (&app.settings, MSG_ERR, "File at %s is not a fifo\n", app.settings.fifo);
 
377
                        close (app.input.fds[1]);
 
378
                        app.input.fds[1] = -1;
 
379
                } else {
 
380
                        FD_SET(app.input.fds[1], &app.input.set);
 
381
                        BarUiMsg (&app.settings, MSG_INFO, "Control fifo at %s opened\n",
 
382
                                        app.settings.fifo);
 
383
                }
374
384
        }
375
385
        app.input.maxfd = app.input.fds[0] > app.input.fds[1] ? app.input.fds[0] :
376
386
                        app.input.fds[1];