From c17911ba268a4a784c57baed1540d08ba8741e04 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 15 Jun 2008 21:23:37 +0200 Subject: client: Config file added, not yet documented Some restructuring was necessary too. --- src/main.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 05d1f4e..a7df2aa 100644 --- a/src/main.c +++ b/src/main.c @@ -31,10 +31,12 @@ THE SOFTWARE. #include #include #include -#include #include #include +#include "terminal.h" +#include "settings.h" + struct aacPlayer { /* buffer */ char *buffer; @@ -278,23 +280,38 @@ int main (int argc, char **argv) { char doQuit = 0; PianoSong_t *curSong = NULL; PianoStation_t *curStation; - struct termios termopts; + BarSettings_t bsettings; /* init some things */ curl_global_init (CURL_GLOBAL_SSL); xmlInitParser (); ao_initialize(); + + BarSettingsInit (&bsettings); + readSettings (&bsettings); + + if (bsettings.username == NULL) { + bsettings.username = readline ("Username: "); + } + if (bsettings.password == NULL) { + termSetEcho (0); + bsettings.password = readline ("Password: "); + termSetEcho (1); + } + PianoInit (&ph); + /* setup control proxy */ + curl_easy_setopt (ph.curlHandle, CURLOPT_PROXY, bsettings.controlProxy); + curl_easy_setopt (ph.curlHandle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A); + curl_easy_setopt (ph.curlHandle, CURLOPT_CONNECTTIMEOUT, 60); /* no buffering for stdin */ - tcgetattr (fileno (stdin), &termopts); - termopts.c_lflag &= ~ICANON; - tcsetattr(fileno (stdin), TCSANOW, &termopts); - setvbuf (stdin, NULL, _IONBF, 1); + termSetBuffer (0); - PianoConnect (&ph, argv[1], argv[2]); + printf ("Login...\n"); + PianoConnect (&ph, bsettings.username, bsettings.password); + printf ("Get stations...\n"); PianoGetStations (&ph); - printf ("webAuthToken: %s\nauthToken: %s\nlistenerId: %s\n", ph.user.webAuthToken, ph.user.authToken, ph.user.listenerId); /* select station */ curStation = selectStation (&ph); @@ -467,6 +484,7 @@ int main (int argc, char **argv) { curl_global_cleanup (); ao_shutdown(); xmlCleanupParser (); + BarSettingsDestroy (&bsettings); return 0; } -- cgit v1.2.3