chiark / gitweb /
Merge branch 'master' of git.distorted.org.uk:~mdw/publish/public-git/disorder
[disorder] / disobedience / login.c
index 36850c11da60b9f201c59da9b0033c3bea1cdedc..fb8cf715875b5421bdddd2bf4890cbb2aee77fde 100644 (file)
@@ -120,11 +120,13 @@ static void set_service(struct config *c, const char *s) {
 }
 
 static void set_username(struct config *c, const char *s) {
-  c->username = s;
+  xfree(c->username);
+  c->username = xstrdup(s);
 }
 
 static void set_password(struct config *c, const char *s) {
-  c->password = s;
+  xfree(c->password);
+  c->password = xstrdup(s);
 }
 
 /** @brief Table used to generate the form */
@@ -154,10 +156,10 @@ static void login_update_config(struct config *c) {
 
 /** @brief Save current login details */
 static void login_save_config(void) {
-  char *path = config_userconf(0, 0), *tmp;
+  char *tmp;
   FILE *fp;
 
-  byte_xasprintf(&tmp, "%s.tmp", path);
+  byte_xasprintf(&tmp, "%s.tmp", userconfigfile);
   /* Make sure the directory exists; don't care if it already exists. */
   mkdir(d_dirname(tmp), 02700);
   /* Write out the file */
@@ -188,7 +190,7 @@ static void login_save_config(void) {
     goto done;
   }
   /* Rename into place */
-  if(rename(tmp, path) < 0) {
+  if(rename(tmp, userconfigfile) < 0) {
     fpopup_msg(GTK_MESSAGE_ERROR, "error renaming %s: %s",
                tmp, strerror(errno));
     goto done;
@@ -230,6 +232,12 @@ static void login_cancel(GtkButton attribute((unused)) *button,
   gtk_widget_destroy(login_window);
 }
 
+/** @brief User pressed cancel in the login window */
+static void login_help(GtkButton attribute((unused)) *button,
+                       gpointer attribute((unused)) userdata) {
+  popup_help("intro.html#login");
+}
+
 /** @brief Keypress handler */
 static gboolean login_keypress(GtkWidget attribute((unused)) *widget,
                                GdkEventKey *event,
@@ -251,16 +259,25 @@ static gboolean login_keypress(GtkWidget attribute((unused)) *widget,
 /* Buttons that appear at the bottom of the window */
 static struct button buttons[] = {
   {
-    "Login",
-    login_ok,
-    "(Re-)connect using these settings",
-    0
+    GTK_STOCK_HELP,
+    login_help,
+    "Go to manual",
+    0,
+    gtk_box_pack_start,
   },
   {
     GTK_STOCK_CLOSE,
     login_cancel,
     "Discard changes and close window",
-    0
+    0,
+    gtk_box_pack_end,
+  },
+  {
+    "Login",
+    login_ok,
+    "(Re-)connect using these settings",
+    0,
+    gtk_box_pack_end,
   },
 };