chiark / gitweb /
disobedience: grey out user management if it won't work.
authorRichard Kettlewell <rjk@terraraq.org.uk>
Sun, 14 Aug 2011 17:08:06 +0000 (18:08 +0100)
committerRichard Kettlewell <rjk@terraraq.org.uk>
Sun, 14 Aug 2011 17:08:06 +0000 (18:08 +0100)
This already worked for users without the 'admin' right but failed on
remote connections if the server had remote_userman set to 'no' (which
is the default).  The result was pretty ugly, the user management
window opened but would repeatedly cause protocol error popups.

The implementation depends on the server change in
b60ceb3caecce2c86c484e6173fb1428b71d456a.

It will still go wrong if remote_userman is changed during the
server's lifetime, presumably a fairly rare event.

disobedience/menu.c

index 435aeb4..272242f 100644 (file)
@@ -215,11 +215,23 @@ void users_set_sensitive(int sensitive) {
   gtk_widget_set_sensitive(w, sensitive);
 }
 
+static void menu_check_userman(void attribute((unused)) *v,
+                               const char *err,
+                               const char attribute((unused)) *value) {
+  if(err && !strncmp(err, "510", 3))
+    users_set_sensitive(FALSE);
+  else
+    users_set_sensitive(TRUE);
+}
+
 /** @brief Called when our rights change */
 static void menu_rights_changed(const char attribute((unused)) *event,
                                 void attribute((unused)) *eventdata,
                                 void attribute((unused)) *callbackdata) {
-  users_set_sensitive(!!(last_rights & RIGHT_ADMIN));
+  if(last_rights & RIGHT_ADMIN)
+    disorder_eclient_userinfo(client, menu_check_userman, "", "email", 0);
+  else
+    users_set_sensitive(FALSE);
 }
 
 /** @brief Create the menu bar widget */