X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/ec7109f36e878732d30e592279c2b160b28e6955..958a94627f6f51a3962c33fe413af3f5c3026af5:/disobedience/login.c diff --git a/disobedience/login.c b/disobedience/login.c index 803dbf4..1c6df79 100644 --- a/disobedience/login.c +++ b/disobedience/login.c @@ -2,20 +2,18 @@ * This file is part of DisOrder * Copyright (C) 2007, 2008 Richard Kettlewell * - * This program is free software; you can redistribute it and/or modify + * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA + * along with this program. If not, see . */ /** @file disobedience/login.c * @brief Login box for Disobedience @@ -71,12 +69,18 @@ GtkWidget *login_window; /** @brief Set connection defaults */ static void default_connect(void) { - if(!config->connect.n) { - config->connect.n = 2; - config->connect.s = xcalloc(2, sizeof (char *)); - config->connect.s[0] = xstrdup("localhost"); - config->connect.s[1] = xstrdup("9999"); /* whatever */ - } + /* If a password is set assume we're good */ + if(config->password) + return; + /* If we already have a host and/or port that's good too */ + if(config->connect.n) + return; + /* If there's a suitable socket that's probably what we wanted */ + const char *s = config_get_file("socket"); + struct stat st; + if(s && *s && stat(s, &st) == 0 && S_ISSOCK(st.st_mode)) + return; + /* TODO can we use some mdns thing to find a DisOrder server? */ } static const char *get_hostname(void) { @@ -322,9 +326,9 @@ void login_box(void) { lwi_entry[n] = entry; } /* Initial settings */ - lwi_remote_toggled(GTK_TOGGLE_BUTTON(lwi_remote), 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lwi_remote), config->connect.n >= 2); + lwi_remote_toggled(GTK_TOGGLE_BUTTON(lwi_remote), 0); buttonbox = create_buttons(buttons, NBUTTONS); vbox = gtk_vbox_new(FALSE, 1); gtk_box_pack_start(GTK_BOX(vbox),