152
137
gboolean transient;
153
138
} prefs_callback_data;
158
static prefs_callback_data *new_prefs_callback_data(struct server_windata *sw)
160
prefs_callback_data *d = g_malloc(sizeof(prefs_callback_data));
162
d->edit_new_server = 0;
167
static void destroy_prefs_callback_data(prefs_callback_data *cb_data) {
169
if (cb_data->edit_new_server) {
170
if (cb_data->server) {
171
gq_server_list_remove(gq_server_list_get(), cb_data->server);
174
if(cb_data->server) {
175
g_object_unref(cb_data->server);
176
cb_data->server = NULL;
183
check_unique_name(GQServerList* list, GqServer* server, gpointer user_data) {
184
gpointer* unique_and_server = user_data;
185
gboolean* unique = unique_and_server[0];
186
GqServer* newserver = unique_and_server[1];
188
if(server != newserver && !strcmp(server->name, newserver->name)) {
193
static void server_edit_callback(GtkWidget *this, prefs_callback_data *cb_data)
195
GtkWidget *window, *field;
196
GqServer *server, *servers;
197
int server_name_changed;
198
const char *text, *passwdtext;
200
#if HAVE_LDAP_CLIENT_CACHE
204
struct server_windata *sw = cb_data->sw;
206
GqServer *save = gq_server_new();
207
gboolean unique = TRUE;
208
gpointer unique_and_server[2] = {
213
server = cb_data->server;
214
copy_ldapserver(save, server);
216
window = sw->editwindow;
219
field = sw->servername;
220
text = gtk_entry_get_text(GTK_ENTRY(field));
221
if(strcmp(text, server->name))
222
server_name_changed = 1;
224
server_name_changed = 0;
226
g_free_and_dup(server->name, text);
228
/* make sure server name is unique */
229
gq_server_list_foreach(gq_server_list_get(), check_unique_name, unique_and_server);
233
error_popup(_("Error adding new server"),
234
_("A server by that name already exists\n\n"
235
"Please choose another name"),
241
field = sw->ldaphost;
242
text = gtk_entry_get_text(GTK_ENTRY(field));
243
g_free_and_dup(server->ldaphost, text);
246
field = sw->ldapport;
247
text = gtk_entry_get_text(GTK_ENTRY(field));
249
server->ldapport = strtol(text, &ep, 10);
252
single_warning_popup(_("Port must be numeric or empty"));
255
/* empty, might have LDAP URI */
256
server->ldapport = -1;
262
text = gtk_entry_get_text(GTK_ENTRY(field));
263
g_free_and_dup(server->basedn, text);
267
text = gtk_entry_get_text(GTK_ENTRY(field));
268
g_free_and_dup(server->binddn, text);
272
server->ask_pw = GTK_TOGGLE_BUTTON(field)->active ? 1 : 0;
275
passwdtext = gtk_entry_get_text(GTK_ENTRY(sw->bindpw));
276
g_free(server->bindpw);
277
if(!server->ask_pw && passwdtext) {
278
server->bindpw = g_strdup(passwdtext);
279
gq_keyring_save_server_password(server);
281
server->bindpw = g_strdup("");
284
/* Search attribute */
285
field = sw->searchattr;
286
text = gtk_entry_get_text(GTK_ENTRY(field));
287
g_free_and_dup(server->searchattr, text);
289
/* Maximum entries */
290
field = sw->maxentries;
291
text = gtk_entry_get_text(GTK_ENTRY(field));
293
server->maxentries = strtol(text, &ep, 10);
296
single_warning_popup(_("Maximum number of entries must be numeric or empty"));
298
/* empty, might have LDAP URI */
299
server->maxentries = 0;
304
field = sw->hide_internal;
305
server->hide_internal = GTK_TOGGLE_BUTTON(field)->active ? 1 : 0;
307
/* Cache connection */
308
field = sw->cacheconn;
309
server->cacheconn = GTK_TOGGLE_BUTTON(field)->active ? 1 : 0;
312
field = sw->enabletls;
313
server->enabletls = GTK_TOGGLE_BUTTON(field)->active ? 1 : 0;
315
#if HAVE_LDAP_CLIENT_CACHE
316
/* Local Cache Timeout */
317
field = sw->localcachetimeout;
318
text = gtk_entry_get_text(GTK_ENTRY(field));
319
tmp = (int) strtol(text, &ep, 0);
320
if (!ep || !*ep) server->local_cache_timeout = tmp;
323
field = GTK_COMBO(sw->bindtype)->entry;
324
text = gtk_entry_get_text(GTK_ENTRY(field));
325
server->bindtype = tokenize(token_bindtype, text);
327
/* connection info might have changed for this server -- close
329
close_connection(server, TRUE);
330
canonicalize_ldapserver(server);
332
if(server_name_changed) {
333
/* refresh clist in serverstab */
334
fill_serverlist_serverstab();
338
/* I do not really like this ad-hoc solution to check if a server
339
is a transient server or a configured one, but ... */
340
if (!is_transient_server(server)) {
341
/* so the cancel button doesn't really cancel :-) */
342
save_ok = save_config(window);
345
/* if (cb_data->edit_new_server) { */
346
/* /\* everything ok, take the server out of the cb_data (in case it */
347
/* was created anew, this will avoid that the cb_data destroy */
348
/* function deletes the ldapserver) *\/ */
349
/* cb_data->server = NULL; */
353
update_serverlist(&mainwin);
354
gtk_widget_destroy(window);
356
copy_ldapserver(server, save);
360
if (save) g_object_unref(save);
363
static void host_changed_callback(GtkEditable *host, GtkWidget *port)
365
gchar *s = gtk_editable_get_chars(host, 0, -1);
368
gtk_widget_set_sensitive(GTK_WIDGET(port),
369
(g_utf8_strchr(s, -1, ':') == NULL));
374
static void destroy_edit_server_window(GtkWidget *this,
375
struct server_windata *sw)
377
if (this == current_edit_server_window) {
378
current_edit_server_window = NULL;
383
static gboolean destroy_edit_server_window_on_esc(GtkWidget *widget,
387
if(event && event->type == GDK_KEY_PRESS && event->keyval == GDK_Escape) {
388
gtk_widget_destroy(widget);
396
toggle_pw_visibility(GtkToggleButton* toggle, GtkEntry* entry) {
397
gboolean visible = gtk_toggle_button_get_active(toggle);
399
if(!visible || question_popup(_("Cleartext Password"),
400
_("The password that you entered will be displayed in\n"
401
"the entry. This can be dangerous if someone is watching\n"
402
"at the screen you're currently working on (that includes\n"
403
"both people behind you and people that may watch your\n"
404
"desktop via VNC).\n\n"
405
"Do you still want to see the password?")))
407
// FIXME: let the user set a "don't display again" switch
408
gtk_entry_set_visibility(entry, visible);
410
// un-toggle the button if the user was not sure about
411
// displaying the password
412
gtk_toggle_button_set_active(toggle, FALSE);
417
ask_pw_toggled(GtkToggleButton *button, struct server_windata *sw) {
418
gboolean sensitive = !gtk_toggle_button_get_active(button);
419
gtk_widget_set_sensitive(sw->bindpw, sensitive);
420
gtk_widget_set_sensitive(sw->show_pw_toggle, sensitive);
421
gtk_widget_set_sensitive(sw->clear_pw, sensitive);
425
clear_pw(GtkButton* button, prefs_callback_data *cb_data) {
426
gtk_entry_set_text(GTK_ENTRY(cb_data->sw->bindpw), "");
427
gq_keyring_forget_password(cb_data->server);
431
create_edit_server_window(GqServer *server,
434
GtkWidget *editwindow, *notebook;
435
GtkWidget *main_vbox, *vbox1, *vbox2, *hbox;
436
GtkWidget *table1, *table2, *table3;
437
GtkWidget *label, *entry, *button;
438
GtkWidget *okbutton, *cancelbutton;
439
GtkWidget *bindpw, *host, *box;
443
char tmp[16]; /* fixed buffer: OK - used for printf("%d") only */
445
GList *bindtypes = NULL;
447
prefs_callback_data *cb_data;
448
struct server_windata *sw = NULL;
449
gchar* password = NULL;
451
if(current_edit_server_window) {
452
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sw->show_pw_toggle), FALSE);
453
gtk_window_present(GTK_WINDOW(current_edit_server_window));
457
tips = gtk_tooltips_new();
459
sw = g_malloc0(sizeof(struct server_windata));
461
cb_data = new_prefs_callback_data(sw);
462
cb_data->edit_new_server = (server == NULL);
463
cb_data->transient = is_transient_server(server);
467
server = gq_server_new();
468
for(i = 1; i < G_MAXINT; i++) {
469
gchar* name = g_strdup_printf(_("Untitled Server %d"), i);
470
if(G_LIKELY(!gq_server_list_get_by_name(gq_server_list_get(),
472
gq_server_set_name(server, name);
478
gq_server_list_add(gq_server_list_get(), server);
481
cb_data->server = g_object_ref(server);
483
editwindow = stateful_gtk_window_new(GTK_WINDOW_TOPLEVEL,
484
"serveredit", -1, -1);
485
sw->editwindow = editwindow;
486
current_edit_server_window = editwindow;
489
g_assert(GTK_IS_WINDOW(modalFor));
490
gtk_window_set_modal(GTK_WINDOW(editwindow), TRUE);
491
gtk_window_set_transient_for(GTK_WINDOW(editwindow),
492
GTK_WINDOW(modalFor));
495
gtk_object_set_data_full(GTK_OBJECT(editwindow),
498
(GtkDestroyNotify) destroy_prefs_callback_data);
500
title = g_string_sized_new(64);
502
if(cb_data->edit_new_server) {
503
g_string_sprintf(title, _("New server"));
505
g_string_sprintf(title, _("Server %s"), server->name);
507
if (cb_data->transient) {
508
g_string_sprintf(title, _("Transient server %s"), server->name);
511
gtk_window_set_title(GTK_WINDOW(editwindow), title->str);
512
g_string_free(title, TRUE);
514
gtk_window_set_policy(GTK_WINDOW(editwindow), TRUE, TRUE, FALSE);
516
main_vbox = gtk_vbox_new(FALSE, 0);
517
gtk_container_border_width(GTK_CONTAINER(main_vbox),
518
CONTAINER_BORDER_WIDTH);
519
gtk_widget_show(main_vbox);
520
gtk_container_add(GTK_CONTAINER(editwindow), main_vbox);
522
notebook = gtk_notebook_new();
523
gtk_widget_show(notebook);
524
#ifdef OLD_FOCUS_HANDLING
525
GTK_WIDGET_UNSET_FLAGS(GTK_NOTEBOOK(notebook), GTK_CAN_FOCUS);
527
gtk_box_pack_start(GTK_BOX(main_vbox), notebook, TRUE, TRUE, 0);
531
vbox1 = gtk_vbox_new(FALSE, 20);
532
gtk_widget_show(vbox1);
533
gtk_container_border_width(GTK_CONTAINER(vbox1),
534
CONTAINER_BORDER_WIDTH);
535
label = gq_label_new(_("_General"));
536
gtk_widget_show(label);
537
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox1, label);
539
table1 = gtk_table_new(4, 2, FALSE);
540
gtk_widget_show(table1);
541
gtk_box_pack_start(GTK_BOX(vbox1), table1, FALSE, FALSE, 0);
542
gtk_container_border_width(GTK_CONTAINER(table1),
543
CONTAINER_BORDER_WIDTH);
544
gtk_table_set_row_spacings(GTK_TABLE(table1), 5);
545
gtk_table_set_col_spacings(GTK_TABLE(table1), 13);
548
label = gq_label_new(_("_Name"));
549
gtk_misc_set_alignment(GTK_MISC(label), 0.0, .5);
550
gtk_widget_show(label);
551
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, 0, 1,
552
GTK_FILL, GTK_FILL, 0, 0);
553
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
555
entry = gtk_entry_new();
557
sw->servername = entry;
559
gtk_entry_set_text(GTK_ENTRY(entry), server->name);
560
gtk_widget_show(entry);
561
g_signal_connect(entry, "activate",
562
G_CALLBACK(server_edit_callback), cb_data);
563
gtk_table_attach(GTK_TABLE(table1), entry, 1, 2, 0, 1,
564
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
565
gtk_widget_grab_focus(entry);
567
gtk_tooltips_set_tip(tips, entry,
568
_("The nickname of the server definition"),
569
Q_("tooltip|The nickname is used to refer to this "
571
"definition throughout this application")
574
gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
577
label = gq_label_new(_("LDAP _Host/URI"));
578
gtk_misc_set_alignment(GTK_MISC(label), 0.0, .5);
579
gtk_widget_show(label);
580
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, 1, 2,
581
GTK_FILL, GTK_FILL, 0, 0);
583
host = entry = gtk_entry_new();
584
sw->ldaphost = entry;
585
gtk_entry_set_text(GTK_ENTRY(entry), server->ldaphost);
587
gtk_widget_show(entry);
588
g_signal_connect(entry, "activate",
589
G_CALLBACK(server_edit_callback), cb_data);
590
gtk_table_attach(GTK_TABLE(table1), entry, 1, 2, 1, 2,
591
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
593
gtk_tooltips_set_tip(tips, entry,
594
_("The host name or LDAP URI of the LDAP server"),
595
Q_("tooltip|Either use the name or IP address of "
597
"or an LDAP URI (either ldap or ldaps). An URI "
598
"is recognized through the existance of a colon "
602
gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
605
label = gq_label_new(_("LDAP _Port"));
606
gtk_misc_set_alignment(GTK_MISC(label), 0.0, .5);
607
gtk_widget_show(label);
608
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, 2, 3,
609
GTK_FILL, GTK_FILL, 0, 0);
611
entry = gtk_entry_new();
612
sw->ldapport = entry;
613
if (server->ldapport != 0) {
614
g_snprintf(tmp, sizeof(tmp), "%d", server->ldapport);
618
gtk_entry_set_text(GTK_ENTRY(entry), tmp);
619
gtk_widget_show(entry);
620
g_signal_connect(entry, "activate",
621
G_CALLBACK(server_edit_callback), cb_data);
622
gtk_table_attach(GTK_TABLE(table1), entry, 1, 2, 2, 3,
623
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
625
gtk_tooltips_set_tip(tips, entry,
626
_("The port the LDAP server listens on"),
627
Q_("tooltip|If empty, the well-known LDAP port (389) "
628
"is assumed. This field is not available if an "
632
/* Callback on HOST to enable/disable PORT if user enters a colon... */
634
g_signal_connect(host, "changed",
635
G_CALLBACK(host_changed_callback), entry);
637
gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
639
g_signal_emit_by_name(host, "changed", NULL, NULL);
642
label = gq_label_new(_("_Base DN"));
643
gtk_misc_set_alignment(GTK_MISC(label), 0.0, .5);
644
gtk_widget_show(label);
645
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, 3, 4,
646
GTK_FILL, GTK_FILL, 0, 0);
648
entry = gtk_entry_new();
650
gtk_entry_set_text(GTK_ENTRY(entry), server->basedn);
651
gtk_widget_show(entry);
652
g_signal_connect(entry, "activate",
653
G_CALLBACK(server_edit_callback), cb_data);
654
gtk_table_attach(GTK_TABLE(table1), entry, 1, 2, 3, 4,
655
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
657
gtk_tooltips_set_tip(tips, entry,
658
_("The base DN of the server"),
659
Q_("tooltip|This base DN gets used in search mode, "
661
"though, this application queries the server "
662
"for its 'namingContexts'")
664
gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
668
/* Add not if the server is transient */
671
if (cb_data->transient) {
672
label = gtk_label_new(_("NOTE: This is a transient server definition. It has been added dynamically and it will not be saved to the permanent configuration."));
674
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
675
gtk_box_pack_start(GTK_BOX(vbox1), label, FALSE, FALSE, 0);
676
gtk_widget_show(label);
681
vbox2 = gtk_vbox_new(FALSE, 0);
682
gtk_widget_show(vbox2);
683
gtk_container_border_width(GTK_CONTAINER(vbox2),
684
CONTAINER_BORDER_WIDTH);
685
label = gq_label_new(_("_Details"));
686
gtk_widget_show(label);
687
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, label);
689
table2 = gtk_table_new(8, 2, FALSE);
690
gtk_widget_show(table2);
691
gtk_box_pack_start(GTK_BOX(vbox2), table2, TRUE, TRUE, 0);
692
gtk_container_border_width(GTK_CONTAINER(table2),
693
CONTAINER_BORDER_WIDTH);
694
gtk_table_set_row_spacings(GTK_TABLE(table2), 5);
695
gtk_table_set_col_spacings(GTK_TABLE(table2), 13);
698
table3 = gtk_table_new(3, 2, FALSE);
699
gtk_widget_show(table3);
700
gtk_box_pack_start(GTK_BOX(vbox2), table3, TRUE, TRUE, 0);
701
gtk_container_border_width(GTK_CONTAINER(table3),
702
CONTAINER_BORDER_WIDTH);
703
gtk_table_set_row_spacings(GTK_TABLE(table3), 5);
704
gtk_table_set_col_spacings(GTK_TABLE(table3), 13);
708
label = gq_label_new(_("_Bind DN"));
709
gtk_misc_set_alignment(GTK_MISC(label), 0.0, .5);
710
gtk_widget_show(label);
711
gtk_table_attach(GTK_TABLE(table2), label, 0, 1, y, y + 1,
712
GTK_FILL, GTK_FILL, 0, 0);
714
entry = gtk_entry_new();
716
gtk_entry_set_text(GTK_ENTRY(entry), server->binddn);
717
gtk_widget_show(entry);
718
g_signal_connect(entry, "activate",
719
G_CALLBACK(server_edit_callback), cb_data);
720
gtk_table_attach(GTK_TABLE(table2), entry, 1, 2, y, y + 1,
721
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
724
gtk_tooltips_set_tip(tips, entry,
725
_("The DN to bind with to the LDAP server"),
726
Q_("tooltip|This is equivalent to a 'username'. "
728
"LDAP administrator for the DN to use.")
731
gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
734
label = gq_label_new(_("Bind _Password"));
735
gtk_misc_set_alignment(GTK_MISC(label), 0.0, .5);
736
gtk_widget_show(label);
737
gtk_table_attach(GTK_TABLE(table2), label, 0, 1, y, y + 1,
738
GTK_FILL, GTK_FILL, 0, 0);
740
box = gtk_hbox_new(FALSE, 3);
741
gtk_table_attach(GTK_TABLE(table2), box, 1, 2, y, y + 1,
742
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
745
sw->bindpw = bindpw = entry = gtk_entry_new();
746
gtk_box_pack_start_defaults(GTK_BOX(box), sw->bindpw);
747
gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
749
password = gq_keyring_get_password(server);
751
gtk_entry_set_text(GTK_ENTRY(sw->bindpw), password ? password : "");
752
g_signal_connect(sw->bindpw, "activate",
753
G_CALLBACK(server_edit_callback), cb_data);
754
gnome_keyring_free_password(password);
758
gtk_tooltips_set_tip(tips, sw->bindpw,
759
_("The password to bind with to the LDAP server"),
760
Q_("tooltip|This is related to the bind DN. Note that the "
761
"password gets stored in a configuration file. "
762
"Recent versions of this application actually "
763
"scramble the password, but this scrambling can "
764
"easily be reverted. Do not use a valuable "
769
gtk_label_set_mnemonic_widget(GTK_LABEL(label), sw->bindpw);
770
gtk_widget_show_all(box);
772
/* the show password button */
773
sw->show_pw_toggle = gtk_toggle_button_new();
774
gtk_container_add(GTK_CONTAINER(sw->show_pw_toggle),
775
gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_MENU));
776
gtk_box_pack_start(GTK_BOX(box), sw->show_pw_toggle, FALSE, FALSE, 0);
777
gtk_tooltips_set_tip(tips, sw->show_pw_toggle,
778
_("Show the password"),
779
Q_("tooltip|Clicking this button asks the user whether "
780
"he really wants to see the password and if that's "
781
"the case, displays the password. Clicking this button "
782
"once more will hide the password."));
783
g_signal_connect(sw->show_pw_toggle, "toggled",
784
G_CALLBACK(toggle_pw_visibility), sw->bindpw);
785
gtk_widget_show_all(sw->show_pw_toggle);
787
/* the delete password button */
788
sw->clear_pw = gtk_button_new();
789
gtk_container_add(GTK_CONTAINER(sw->clear_pw),
790
gtk_image_new_from_stock(GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU));
791
gtk_box_pack_start(GTK_BOX(box), sw->clear_pw, FALSE, FALSE, 0);
792
gtk_tooltips_set_tip(tips, sw->clear_pw,
793
_("Clear the Password"),
794
Q_("tooltip|Clicking this button asks the user whether "
795
"he really wants to clear the password and if that's "
796
"the case, clears the password entry and deletes the "
797
"password from the keyring."));
798
g_signal_connect(sw->clear_pw, "clicked",
799
G_CALLBACK(clear_pw), cb_data);
800
gtk_widget_show_all(sw->clear_pw);
803
label = gq_label_new(_("Bind t_ype"));
804
gtk_misc_set_alignment(GTK_MISC(label), 0.0, .5);
805
gtk_widget_show(label);
806
gtk_table_attach(GTK_TABLE(table2), label, 0, 1, y, y + 1,
807
GTK_FILL, GTK_FILL, 0, 0);
809
bindtype = gtk_combo_new();
810
sw->bindtype = bindtype;
813
token_bindtype[i].keyword && strlen(token_bindtype[i].keyword);
815
bindtypes = g_list_append(bindtypes,
816
GINT_TO_POINTER(token_bindtype[i].keyword));
819
gtk_combo_set_popdown_strings(GTK_COMBO(bindtype), bindtypes);
820
g_list_free(bindtypes);
822
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(bindtype)->entry), FALSE);
823
gtk_widget_show(bindtype);
825
gtk_list_select_item(GTK_LIST(GTK_COMBO(bindtype)->list),
827
gtk_table_attach(GTK_TABLE(table2), bindtype, 1, 2, y, y + 1,
828
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
831
gtk_tooltips_set_tip(tips, GTK_WIDGET(GTK_COMBO(bindtype)->entry),
832
_("How to bind to the LDAP server"),
833
Q_("tooltip|gq supports several different bind "
834
"types, like Simple, Kerberos or SASL binds.")
837
gtk_label_set_mnemonic_widget(GTK_LABEL(label),
838
GTK_COMBO(bindtype)->entry);
840
/* Search attribute */
841
label = gq_label_new(_("_Search Attribute"));
842
gtk_misc_set_alignment(GTK_MISC(label), 0.0, .5);
843
gtk_widget_show(label);
844
gtk_table_attach(GTK_TABLE(table2), label, 0, 1, y, y + 1,
845
GTK_FILL, GTK_FILL, 0, 0);
847
entry = gtk_entry_new();
848
sw->searchattr = entry;
849
gtk_entry_set_text(GTK_ENTRY(entry), server->searchattr);
850
gtk_widget_show(entry);
851
g_signal_connect(entry, "activate",
852
G_CALLBACK(server_edit_callback), cb_data);
853
gtk_table_attach(GTK_TABLE(table2), entry, 1, 2, y, y + 1,
854
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
857
gtk_tooltips_set_tip(tips, entry,
858
_("The attribute to 'search' in a search tab."),
859
Q_("tooltip|Search mode in the search tab searches "
860
"this attribute. This alleviates the user to "
861
"always use a proper LDAP filter.")
863
gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
865
/* Maximum entries */
866
label = gq_label_new(_("_Maximum entries"));
867
gtk_misc_set_alignment(GTK_MISC(label), 0.0, .5);
868
gtk_widget_show(label);
869
gtk_table_attach(GTK_TABLE(table2), label, 0, 1, y, y + 1,
870
GTK_FILL, GTK_FILL, 0, 0);
872
entry = gtk_entry_new();
873
sw->maxentries = entry;
874
g_snprintf(tmp, sizeof(tmp), "%d", server->maxentries);
875
gtk_entry_set_text(GTK_ENTRY(entry), tmp);
876
gtk_widget_show(entry);
877
g_signal_connect(entry, "activate",
878
G_CALLBACK(server_edit_callback), cb_data);
879
gtk_table_attach(GTK_TABLE(table2), entry, 1, 2, y, y + 1,
880
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
883
gtk_tooltips_set_tip(tips, entry,
884
_("The maximum number of entries to return in "
886
Q_("tooltip|NOTE: A server might impose stricter "
890
gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
892
#if HAVE_LDAP_CLIENT_CACHE
140
#warning "FIXME: enable the client cache timeout setting in the server dialog"
141
#if 0 ||HAVE_LDAP_CLIENT_CACHE
893
142
/* Use local cache */
894
143
label = gq_label_new(_("LDAP cache timeo_ut"));
895
144
gtk_misc_set_alignment(GTK_MISC(label), 0.0, .5);
923
/* Ask password on first connect */
924
button = gq_check_button_new_with_label(_("_Ask password on first connect"));
926
g_signal_connect(button, "toggled",
927
G_CALLBACK(ask_pw_toggled), sw);
929
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), server->ask_pw);
931
#ifdef OLD_FOCUS_HANDLING
932
GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS);
934
gtk_widget_show(button);
935
gtk_table_attach(GTK_TABLE(table3), button, 0, 1, z, z + 1,
936
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
938
gtk_tooltips_set_tip(tips, button,
939
_("Should the application ask for a bind password?"),
940
Q_("tooltip|This disables the password entered via "
941
"the preferences dialog. ")
944
/* Hide internal attributes */
945
button = gq_check_button_new_with_label(_("_Hide internal attributes"));
946
sw->hide_internal = button;
947
if(server->hide_internal)
948
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
949
#ifdef OLD_FOCUS_HANDLING
950
GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS);
952
gtk_widget_show(button);
953
gtk_table_attach(GTK_TABLE(table3), button, 1, 2, z, z + 1,
954
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
956
gtk_tooltips_set_tip(tips, button,
957
_("Do not show attributes internal to the LDAP "
959
Q_("tooltip|At least OpenLDAP allows to view "
961
"interesting attributes. Setting this option "
965
/* Cache connections */
966
button = gq_check_button_new_with_label(_("Cach_e connection"));
967
sw->cacheconn = button;
968
if(server->cacheconn)
969
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
970
#ifdef OLD_FOCUS_HANDLING
971
GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS);
973
gtk_widget_show(button);
974
gtk_table_attach(GTK_TABLE(table3), button, 0, 1, z, z + 1,
975
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
977
gtk_tooltips_set_tip(tips, button,
978
_("If set: Do not close the connection between "
980
Q_("tooltip|Setting this may speed up LDAP "
981
"operations, as it does not require the overhead "
983
"connection to the server for every operation. "
984
"OTOH it might put additional stress on the "
985
"server (depends on what you call 'stress')")
991
button = gq_check_button_new_with_label(_("Enable _TLS"));
992
sw->enabletls = button;
993
if(server->enabletls)
994
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
995
#ifdef OLD_FOCUS_HANDLING
996
GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS);
998
gtk_widget_show(button);
999
gtk_table_attach(GTK_TABLE(table3), button, 0, 1, z, z + 1,
1000
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1003
gtk_tooltips_set_tip(tips, button,
1004
_("Should we use Transport Layer Security?"),
1005
Q_("tooltip|Almost but not quite entirely SSL.")
1008
/* OK and Cancel buttons */
1009
hbox = gtk_hbutton_box_new(); /* FALSE, 13); */
1010
/* gtk_container_border_width(GTK_CONTAINER(hbox), 10); */
1011
gtk_widget_show(hbox);
1012
gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, TRUE, 10);
1015
okbutton = gtk_button_new_from_stock(GTK_STOCK_OK);
1017
gtk_widget_show(okbutton);
1018
g_signal_connect(okbutton, "clicked",
1019
G_CALLBACK(server_edit_callback),
1021
gtk_box_pack_start(GTK_BOX(hbox), okbutton, FALSE, TRUE, 10);
1022
GTK_WIDGET_SET_FLAGS(okbutton, GTK_CAN_DEFAULT);
1023
gtk_widget_grab_default(okbutton);
1025
cancelbutton = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
1027
gtk_widget_show(cancelbutton);
1028
g_signal_connect_swapped(cancelbutton, "clicked",
1029
G_CALLBACK(gtk_widget_destroy),
1031
g_signal_connect(editwindow, "key_press_event",
1032
G_CALLBACK(destroy_edit_server_window_on_esc),
1034
g_signal_connect(editwindow, "destroy",
1035
G_CALLBACK(destroy_edit_server_window),
1039
gtk_box_pack_end(GTK_BOX(hbox), cancelbutton, FALSE, TRUE, 10);
1041
gtk_widget_show(editwindow);
1043
statusbar_msg(_("Server properties window opened for server '%s'"),
1049
173
serverstab_deletebutton_callback(GtkWidget* widget,
1050
174
struct prefs_windata* pw)
1052
GtkWidget *clist = pw->serverstab_server_clist;
1053
gint row = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(clist), "selected-row"));
1054
GqServer *server = gtk_clist_get_row_data(GTK_CLIST(clist), row);
180
#warning "FIXME: this check should be unnecessary if the button is disabled without selection"
181
if(!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(pw->serverstab_server_view)),
187
server = gq_server_model_get_server(GQ_SERVER_MODEL(model), &iter);
1057
189
GQServerList* list = gq_server_list_get();
1059
191
g_object_ref(server);
1060
192
gq_server_list_remove(list, server);
1062
194
if (save_config(widget)) {
1063
/* unref server due to removal of the server from
1064
the list of servers */
1065
g_object_unref(server);
1067
gtk_object_remove_data(GTK_OBJECT(clist),
1070
fill_serverlist_serverstab();
1071
195
update_serverlist(&mainwin);
1073
197
/* undo changes */