+static rights_type users_get_rights(void) {
+ rights_type r = 0;
+ int n;
+
+ /* Extract the rights value */
+ for(n = 0; n < 32; ++n) {
+ if(users_details_rights[n])
+ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(users_details_rights[n])))
+ r |= 1 << n;
+ }
+ /* Throw out redundant bits */
+ if(r & RIGHT_REMOVE_ANY)
+ r &= ~(rights_type)(RIGHT_REMOVE_MINE|RIGHT_REMOVE_RANDOM);
+ if(r & RIGHT_MOVE_ANY)
+ r &= ~(rights_type)(RIGHT_MOVE_MINE|RIGHT_MOVE_RANDOM);
+ if(r & RIGHT_SCRATCH_ANY)
+ r &= ~(rights_type)(RIGHT_SCRATCH_MINE|RIGHT_SCRATCH_RANDOM);
+ return r;
+}
+
+/** @brief Called when various things fail */
+static void users_op_failed(struct callbackdata attribute((unused)) *cbd,
+ int attribute((unused)) code,
+ const char *msg) {
+ popup_submsg(users_window, GTK_MESSAGE_ERROR, msg);
+}
+
+/** @brief Called when a new user has been created */
+static void users_adduser_completed(void *v) {
+ struct callbackdata *cbd = v;
+
+ /* Now the user is created we can go ahead and set the email address */
+ if(*cbd->u.edituser.email) {
+ struct callbackdata *ncbd = xmalloc(sizeof *cbd);
+ ncbd->onerror = users_op_failed;
+ disorder_eclient_edituser(client, NULL, cbd->u.edituser.user,
+ "email", cbd->u.edituser.email, ncbd);
+ }
+ /* Refresh the list of users */
+ disorder_eclient_users(client, users_got_list, 0);
+ /* We'll select the newly created user */
+ users_deferred_select = cbd->u.edituser.user;
+}
+
+/** @brief Called if creating a new user fails */
+static void users_adduser_failed(struct callbackdata attribute((unused)) *cbd,
+ int attribute((unused)) code,
+ const char *msg) {
+ popup_submsg(users_window, GTK_MESSAGE_ERROR, msg);
+ mode(ADD); /* Let the user try again */
+}
+