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

« back to all changes in this revision

Viewing changes to src/main.c

  • Committer: Package Import Robot
  • Author(s): Luke Faraone
  • Date: 2011-11-16 14:26:36 UTC
  • mfrom: (1.3.6)
  • Revision ID: package-import@ubuntu.com-20111116142636-x2v716fs6wrybq46
Tags: 2011.11.11-1
* New upstream version 
  - SSL support and XMLRPC api version compatibility (v33) 
    (closes: #648209, LP: #887886)

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
        }
137
137
        /* no autostart? ask the user */
138
138
        if (app->curStation == NULL) {
139
 
                app->curStation = BarUiSelectStation (app, "Select station: ", NULL);
 
139
                app->curStation = BarUiSelectStation (app, app->ph.stations, "Select station: ", NULL);
140
140
        }
141
141
        if (app->curStation != NULL) {
142
142
                BarUiPrintStation (&app->settings, app->curStation);
192
192
                /* setup player */
193
193
                memset (&app->player, 0, sizeof (app->player));
194
194
 
195
 
                WaitressInit (&app->player.waith);
 
195
                WaitressInit (&app->player.waith, NULL);
196
196
                WaitressSetUrl (&app->player.waith, app->playlist->audioUrl);
197
197
 
198
198
                /* set up global proxy, player is NULLed on songfinish */
328
328
        static BarApp_t app;
329
329
        /* terminal attributes _before_ we started messing around with ~ECHO */
330
330
        struct termios termOrig;
 
331
        WaitressReturn_t wRet;
331
332
 
332
333
        memset (&app, 0, sizeof (app));
333
334
 
338
339
 
339
340
        /* init some things */
340
341
        ao_initialize ();
 
342
        gnutls_global_init ();
341
343
        PianoInit (&app.ph);
342
344
 
343
 
        WaitressInit (&app.waith);
344
 
        app.waith.url.host = strdup (PIANO_RPC_HOST);
345
 
        app.waith.url.port = strdup (PIANO_RPC_PORT);
346
 
 
347
345
        BarSettingsInit (&app.settings);
348
346
        BarSettingsRead (&app.settings);
349
347
 
357
355
                                app.settings.keys[BAR_KS_HELP]);
358
356
        }
359
357
 
 
358
        if ((wRet = WaitressInit (&app.waith, app.settings.tlsCaPath)) != WAITRESS_RET_OK) {
 
359
                if (wRet == WAITRESS_RET_TLS_TRUSTFILE_ERR) {
 
360
                        BarUiMsg (&app.settings, MSG_ERR, "Can't load root certificates. "
 
361
                                        "Please check the tls_ca_path setting in your config file.\n");
 
362
                } else {
 
363
                        BarUiMsg (&app.settings, MSG_ERR, "Can't initialize HTTP library: "
 
364
                                        "%s\n", WaitressErrorToStr (wRet));
 
365
                }
 
366
                goto die;
 
367
        }
 
368
 
 
369
        app.waith.url.host = strdup (PIANO_RPC_HOST);
 
370
        app.waith.url.tls = true;
 
371
 
360
372
        /* init fds */
361
373
        FD_ZERO(&app.input.set);
362
374
        app.input.fds[0] = STDIN_FILENO;
376
388
 
377
389
        BarMainLoop (&app);
378
390
 
 
391
die:
379
392
        if (app.input.fds[1] != -1) {
380
393
                close (app.input.fds[1]);
381
394
        }
383
396
        PianoDestroy (&app.ph);
384
397
        PianoDestroyPlaylist (app.songHistory);
385
398
        PianoDestroyPlaylist (app.playlist);
 
399
        WaitressFree (&app.waith);
386
400
        ao_shutdown();
 
401
        gnutls_global_deinit ();
387
402
        BarSettingsDestroy (&app.settings);
388
403
 
389
404
        /* restore terminal attributes, zsh doesn't need this, bash does... */