-
Notifications
You must be signed in to change notification settings - Fork 4
/
ui.ycp
1633 lines (1454 loc) · 40 KB
/
ui.ycp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* File:
* include/mail/ui.ycp
*
* Package:
* Configuration of mail
*
* Summary:
* User interface functions.
*
* Authors:
* Martin Vidner <mvidner@suse.cz>
*
* $Id$
*
* All user interface functions.
*
*/
{
textdomain "mail";
import "Wizard";
import "Progress";
import "Mode";
import "Mail";
import "MailAliases";
import "Hostname";
import "CWMFirewallInterfaces";
import "Popup";
import "Label";
import "Sequencer";
import "Package";
include "mail/helps.ycp";
include "mail/wj.ycp";
/**
* Read settings dialog
* @return `abort or `next
*/
define symbol ReadDialog () ``{
Wizard::SetScreenShotName ("mail-0-read");
// Set help text
Wizard::RestoreHelp (ReadDialogHelp ());
// A callback function for abort
block<boolean> callback = ``{
return UI::PollInput () == `abort;
};
// Read the configuration
boolean was_ok = true;
if (Mode::screen_shot())
{
Mail::Fake ();
// make it possible to snap this dialog
sleep (3000);
UI::PollInput ();
}
else
{
was_ok = Mail::Read ( callback );
}
// TODO FIXME possibly handle the abort
if (was_ok)
{
if (! Mail::CreateConfig ())
{
string setting = "MAIL_CREATE_CONFIG";
// Translators: continue/cancel dialog
// %1 is a sysconfig variable name
was_ok = Popup::ContinueCancel (sformat (_("The setting %1 is turned off. You have
probably modified the configuration files directly.
If you continue, it will be turned on and
Config Postfix will overwrite manual changes.
"), setting));
}
}
else
{
if (Mail::mta == `other)
{
// After text freeze, but
// a) either something is very broken -> user must know
// b) user installed a different MTA -> knowledgeable enough to
// ba) never see this message anyway
// bb) read English
// TODO: look at exim and mention it in the popup
// Translators: error popup
Popup::Error (_("YaST can only configure Postfix and Sendmail,
but neither of them is installed."));
}
}
Wizard::RestoreScreenShotName ();
return ( was_ok? `next : `abort );
}
/**
* Confirmation dialog before saving and installing needed packages
* @return `back or `next
*/
define symbol ConfirmDialog () ``{
// not to be displayed, #37554.
// but ProbePackages still has to be called.
// continue-cancel popup
string message1 = _("The configuration will be written now.\n");
string message2 = Mail::ProbePackages ();
// return Popup::ContinueCancel (message1 + message2) ? `next : `back;
return `next;
}
/**
* Write settings dialog
* @return `abort or `next
*/
define symbol WriteDialog () ``{
if (Mode::screen_shot())
{
y2milestone ("Screenshot mode - skipping Write");
return `next;
}
// Install packages if needed.
// Cannot do it in Write, autoinstall does it differently.
if (size (Mail::install_packages) > 0 || size (Mail::remove_packages) > 0)
{
Package::DoInstallAndRemove (Mail::install_packages, Mail::remove_packages);
}
// Set help text
Wizard::RestoreHelp (WriteDialogHelp ());
// A callback function for abort
block<boolean> callback = ``{
return UI::PollInput () == `abort;
};
// Read the configuration
boolean was_ok = Mail::Write ( callback);
// TODO FIXME possibly handle the abort
return ( was_ok? `next : `abort );
}
/**
* MTA selection dialog
* (only for autoinstallation, otherwise probed in Mail::Read)
* @return `abort or `next
*/
define symbol MtaSelectionDialog () ``{
Wizard::SetScreenShotName ("mail-0-mta");
symbol mta = Mail::mta;
// for now. TODO: disable Next if none selected
if (mta != `sendmail && mta != `postfix)
{
mta = `postfix;
}
// Translators: dialog caption
// Mailer: Sendmail or Postfix
string caption = _("Mail transfer agent");
term contents =
`Frame (
// Translators: frame label
// Mailer: Sendmail or Postfix
_("Mail transfer agent"),
`RadioButtonGroup (
`id (`mtag),
`HSquash (
`VBox (
`HSpacing (23), // qt bug workaround, #23979
`VSpacing (0.2),
// MTA name does not need translation
`Left (`RadioButton (`id (`sendmail), `opt(`autoShortcut), "Sendmail", mta == `sendmail)),
// MTA name does not need translation
`Left (`RadioButton (`id (`postfix), `opt(`autoShortcut), "Postfix", mta == `postfix)),
`VSpacing (0.2)
)
)
)
);
Wizard::SetContentsButtons (caption, contents, MtaSelectionDialogHelp (), Label::BackButton (), Label::NextButton ());
any ret = nil;
while (true)
{
ret = UI::UserInput ();
if (ret == `cancel)
{
ret = `abort;
}
if (ret == `back || ret == `next ||
(ret == `abort && Popup::ReallyAbort (Mail::touched)))
{
break;
}
}
if (ret == `next)
{
mta = (symbol) UI::QueryWidget (`id (`mtag), `CurrentButton);
Mail::Touch (Mail::mta != mta);
Mail::mta = mta;
}
Wizard::RestoreScreenShotName ();
return (symbol) ret;
}
/**
* A command line argument can override what is read from SCR.
* Used when starting mail from lan/modem.
*/
symbol preselect_connection_type = nil;
/**
* D1
* @return `back, `abort, `next or `none
*/
define symbol ConnectionTypeDialog () ``{
Wizard::SetScreenShotName ("mail-1-conntype");
list widgets = [];
symbol ct = Mail::connection_type;
boolean ama = Mail::use_amavis;
if (preselect_connection_type != nil)
{
ct = preselect_connection_type;
}
// Translators: dialog caption
string caption = _("General Settings");
term contents =
`Frame (
// Translators: frame label
_("Connection type"),
RadioButtonVBox (
`ctg,
[
// Translators: radio button label
`RadioButton (`id (`permanent), `opt (`notify), _("&Permanent"), ct == `permanent),
// Translators: radio button label
`RadioButton (`id (`dialup), `opt (`notify), _("&Dial-up"), ct == `dialup),
// Translators: radio button label
`RadioButton (`id (`none), `opt (`notify), _("No &connection"), ct == `none),
// Translators: radio button label
`RadioButton (`id (`nodaemon), `opt (`notify), _("Do not start Postfix as Daemon"), ct == `nodaemon),
]
)
);
term amavis_t = `Left (WJ_MakeWidget (`use_amavis));
widgets = add (widgets, `use_amavis);
term dkim_t = `Left (WJ_MakeWidget (`use_dkim));
widgets = add (widgets, `use_dkim);
contents = `HSquash (
`VBox (
contents,
`VSpacing (1),
amavis_t,
dkim_t
)
);
Wizard::SetContentsButtons (caption, contents,
WJ_MakeHelp (
prepend (widgets,
ConnectionTypeDialogHelp ())),
Label::BackButton (), Label::NextButton ());
any ret = nil;
while (true)
{
ct = (symbol) UI::QueryWidget (`id (`ctg), `CurrentButton);
if (ct == `permanent || ct == `dialup)
{
UI::ChangeWidget (`id (`use_amavis), `Enabled, true);
UI::ChangeWidget (`id (`use_dkim), `Enabled, true);
Wizard::RestoreNextButton();
}
else if (ct == `nodaemon)
{
UI::ChangeWidget (`id (`use_amavis), `Value, false);
UI::ChangeWidget (`id (`use_amavis), `Enabled, false);
UI::ChangeWidget (`id (`use_dkim), `Value, false);
UI::ChangeWidget (`id (`use_dkim), `Enabled, false);
}
else if (ct == `none)
{
UI::ChangeWidget (`id (`use_amavis), `Value, false);
UI::ChangeWidget (`id (`use_amavis), `Enabled, false);
UI::ChangeWidget (`id (`use_dkim), `Value, false);
UI::ChangeWidget (`id (`use_dkim), `Enabled, false);
Wizard::SetNextButton(`next, Label::FinishButton() );
}
ama = (boolean) UI::QueryWidget (`id (`use_amavis), `Value);
if(ama)
{
UI::ChangeWidget (`id (`use_dkim), `Enabled, true);
}
else
{
UI::ChangeWidget (`id (`use_dkim), `Value, false);
UI::ChangeWidget (`id (`use_dkim), `Enabled, false);
}
ret = UI::UserInput ();
if (ret == `cancel)
{
ret = `abort;
}
if (ret == `back ||
(ret == `abort && Popup::ReallyAbort (Mail::touched)))
{
break;
}
else if (ret == `next)
{
if (WJ_Validate (widgets))
{
break;
}
}
}
if (ret == `next)
{
WJ_Set (widgets);
ct = (symbol) UI::QueryWidget (`id (`ctg), `CurrentButton);
Mail::Touch (Mail::connection_type != ct);
Mail::connection_type = ct;
ret = (ct == `none)? `none: ret;
}
// avoid overriding the choice the user has made
preselect_connection_type = nil;
Wizard::RestoreScreenShotName ();
return (symbol) ret;
}
/**
* D2
* @return `back, `abort, `next or `outgoing_details
*/
define symbol OutgoingDialog () ``{
Wizard::SetScreenShotName ("mail-21-outgoing");
boolean TLSnone = ( Mail::smtp_use_TLS == "no" );
boolean TLSuse = ( Mail::smtp_use_TLS == "yes" );
boolean TLSmust = ( Mail::smtp_use_TLS == "must" );
// what buttons can be used to leave this dialog
//(except the std wizarding ones)
list<symbol> buttons = [];
list<symbol> widgets = [
`outgoing_mail_server,
];
// Translators: dialog caption
string caption = _("Outgoing Mail");
term o_contents =
`VSquash (
`VBox (
WJ_MakeWidget (`outgoing_mail_server),
// TLS
`Label (_("The server uses &TLS.")),
`RadioButtonGroup(`id(`TLS),
`HBox(
`Left(`RadioButton(`id("no"), _("No"), TLSnone)),
`Left(`RadioButton(`id("yes"), _("Use"), TLSuse)),
`Left(`RadioButton(`id("must"), _("Enforce"),TLSmust))
)
),
`HBox(
`PushButton (`id(`outgoing_details), _("&Masquerading")),
`PushButton (`id(`outgoing_auth_opts), _("&Authentication"))
)
)
);
buttons = add (buttons, `outgoing_details);
buttons = add (buttons, `outgoing_auth_opts);
// frame label
term o_frame = `Frame (_("Outgoing Mail"), o_contents);
term contents = `HSquash ( `VBox (
`VStretch (),
o_frame,
`VStretch ()
));
string help = ""; //TODO
Wizard::SetContentsButtons (
caption, contents, WJ_MakeHelp (widgets),
Label::BackButton (),
Label::NextButton ());
symbol ret = nil;
while (true)
{
ret = (symbol) UI::UserInput ();
if (ret == `cancel)
{
ret = `abort;
}
if (ret == `back ||
(ret == `abort && Popup::ReallyAbort (Mail::touched)))
{
break;
}
else if (ret == `next || contains (buttons, ret))
{
// input validation
// For consistency, all querywidgets are done here
if (WJ_Validate (widgets))
{
// all checks OK, break the input loop
break;
}
}
}
if (ret == `next || contains (buttons, ret))
{
Mail::smtp_use_TLS = (string)UI::QueryWidget (`id (`TLS), `Value);
WJ_Set (widgets);
}
Wizard::RestoreScreenShotName ();
return (symbol) ret;
}
/**
* D2
* @return `back, `abort, `next or `outgoing_details
*/
define symbol IncomingDialog () ``{
Wizard::SetScreenShotName ("mail-22-incoming");
list<any> buttons = [];
// watch out, fm_widgets are not part of widgets
// because of special validation requirements
list<symbol> widgets = [
`listen_remote,
];
// firewall widget using CWM
map<string, any> fw_settings = $[
"services": [ "service:smtp" ],
"display_details": true,
];
map<string,any> fw_cwm_widget = CWMFirewallInterfaces::CreateOpenFirewallWidget (fw_settings);
// Translators: dialog caption
string caption = _("Incoming Mail");
term i_contents = `VBox ();
i_contents = add (i_contents, `Left (WJ_MakeWidget (`listen_remote)));
i_contents = add (i_contents, fw_cwm_widget["custom_widget"]:`Empty ());
list<symbol> fm_widgets = [];
if (true) // always embed the first account
{
// Edit the first fetchmail item here.
// Copy it into the edit buffer.
fetchmail_item = Mail::fetchmail[0]:$[];
fm_widgets = [
`fm_server,
`fm_protocol,
`fm_remote_user,
`fm_password,
`fm_local_user,
];
term fm_contents = `VBox (
`HSpacing (40), // prevent fm_password being squashed in curses
`HBox (
WJ_MakeWidget (`fm_server),
`HSpacing (1),
WJ_MakeWidget (`fm_protocol)
),
`HBox (
WJ_MakeWidget (`fm_remote_user),
`HSpacing (1),
WJ_MakeWidget (`fm_password)
),
`HBox (
`Bottom (WJ_MakeWidget (`fm_local_user)),
`HSpacing (1),
// pushbutton
`Bottom (`PushButton (`id (`downloading), `opt (`key_F7), _("&Details...")))
),
`HBox (
`Left(`ComboBox (`id (`fm_start),_("Start &fetchmail"),["manual","daemon"]))
)
);
// frame label: mail downloading (fetchmail)
term fm_frame = `Frame (_("&Downloading"), fm_contents);
i_contents = add (i_contents,
`HBox (
`HSpacing (1),
fm_frame,
`HSpacing (1)
)
);
}
i_contents = add (i_contents, WJ_MakeWidget (`root_alias));
widgets = add (widgets, `root_alias);
if (Mail::mta == `postfix)
{
i_contents = add (i_contents, WJ_MakeWidget (`delivery_mode));
widgets = add (widgets, `delivery_mode);
}
i_contents = add (
i_contents,
// menu button: details of incoming mail
`HBox(
`PushButton (`id (`aliases), _("&Aliases...")),
`PushButton (`id (`virtual), _("&Virtual domains..."))
)
);
buttons = flatten ([buttons, [`downloading, `aliases, `virtual]]);
// frame label
// term i_frame = `Frame (_("Incoming Mail"), i_contents);
term contents = `HSquash ( `VBox (
`VStretch (),
i_contents,
`VStretch ()
));
string help = ""; //TODO
Wizard::SetContentsButtons (
caption, contents, WJ_MakeHelp (widgets) + fw_cwm_widget["help"]:"",
Label::BackButton (),
Label::FinishButton ());
// set combo boxes to proper values
WJ_GetWidget (`fm_protocol);
WJ_GetWidget (`fm_local_user);
WJ_GetWidget (`delivery_mode);
// initialize the widget (set the current value)
CWMFirewallInterfaces::OpenFirewallInit (fw_cwm_widget, "");
UI::ChangeWidget(`id(`fm_start),`Value, Mail::fetchmail_mode);
// nothing entered in the dowloading items - don't save them
boolean fm_empty = true;
map event = nil;
any ret = nil;
while (true)
{
event = UI::WaitForEvent ();
ret = event["ID"]:nil;
if (ret == `cancel)
{
ret = `abort;
}
// handle the events, enable/disable the button, show the popup if button clicked
CWMFirewallInterfaces::OpenFirewallHandle (fw_cwm_widget, "", event);
if (ret == `back ||
(ret == `abort && Popup::ReallyAbort (Mail::touched)))
{
break;
}
else if (ret == `next || contains (buttons, ret))
{
Mail::fetchmail_mode = (string) UI::QueryWidget(`id (`fm_start), `Value);
// input validation
// For consistency, all querywidgets are done here
if (WJ_Validate (widgets))
{
fm_empty =
UI::QueryWidget(`id (`fm_server), `Value) == "" &&
UI::QueryWidget(`id (`fm_remote_user), `Value) == "" &&
UI::QueryWidget(`id (`fm_password), `Value) == "" &&
UI::QueryWidget(`id (`fm_local_user), `Value) == "";
if (fm_empty || WJ_Validate (fm_widgets))
{
// all checks OK, break the input loop
break;
}
}
}
}
if (ret == `next || contains (buttons, ret))
{
WJ_Set (widgets);
// grab current settings, store them to SuSEFirewall::
CWMFirewallInterfaces::OpenFirewallStore (fw_cwm_widget, "", event);
if (!fm_empty)
{
WJ_Set (fm_widgets);
// CHECK: aliasing is not harmful here
Mail::fetchmail[0] = fetchmail_item;
// -------------- fix of bug #29919:
// -------------- propose local domains when fetchmail is used:
if (Mail::fetchmail != [] && Mail::local_domains == [] &&
Mail::mta == `postfix)
{
list<string> ld = [ "\\$myhostname",
"localhost.\\$mydomain",
"\\$mydomain" ];
// popup text
// %1: variable name (eg. POSTFIX_LOCALDOMAINS)
// %2: file name (eg. /etc/sysconfig/postfix)
// %3: value (about 50 characters)
if (Popup::YesNo (sformat (_("To be able to deliver mail to your local MTA,
the value of %1 in %2 will be set to
\"%3\"."), "POSTFIX_LOCALDOMAINS", "/etc/sysconfig/postfix", mergestring (ld, ", "))))
{
Mail::local_domains = ld;
}
}
}
}
Wizard::RestoreScreenShotName ();
return (symbol) ret;
}
/**
* (taken from y2c_users ui.ycp)
* @param username a string
* @return Whether a string contains only valid user name characters
*/
define boolean check_username (string username) ``{
//DUH, auth_dialogs.ycp, users.ycp and Users.ycp have conflicing definitions!
string valid_logname_chars = "0123456789abcdefghijklmnopqrstuvwxyz-_";
string firstchar = substring (username, 0, 1);
return username != "" &&
( (firstchar >= "a" && firstchar <= "z" ) || firstchar == "_" ) &&
findfirstnotof (username, valid_logname_chars) == nil;
}
/**
* (taken from y2c_users ui.ycp)
* @return Describe a valid username
*/
define string valid_username () ``{
// There is a check whether the information from the UI is
// correct and complete. The login name may contain only
// certain characters and must begin with a letter.
// Already in Translation Memory
return _("The user login may contain only
lower case letters, digits, \"-\" and \"_\"
and must begin with a letter or \"_\".
Please try again.
");
}
/**
* See RFC 2822, 3.4
* But for now, no-spaces@valid_domainname
* @param address an address to check
* @return valid?
*/
define boolean check_mail_address (string address) ``{
list<string> parts = splitstring (address, "@");
if (size (parts) != 2)
{
return false;
}
return check_mail_local_part (parts[0]:"")
&& Hostname::CheckDomain (parts[1]:"");
}
/**
* D2.1.1
* Used for adding and editing a user masquerading entry.
* @param defaultv $["user": "address":] or just $[]
* @param existing current masqueading list
* @return $["comment": "", "user": "address":] or $[] on cancel
*/
define map MasqueradeUserPopup (map defaultv, list<map> existing) ``{
string user = defaultv["user"]:"";
string address = defaultv["address"]:"";
list<string> forbidden = maplist (map e, existing, ``( e["user"]:"" ));
term contents =
`HBox(
`HSpacing(1),
`VBox(
`VSpacing(0.2),
// Translators: popup dialog heading
`Heading (_("Sender address rewriting")),
Mode::config () ?
// Translators: text entry label
`Left (`TextEntry (`id (`user), _("&Local user"), user)) :
`Left (`ComboBox (`id (`user), `opt (`editable, `hstretch), _("&Local user"), GetLocalUsers ())),
// Translators: text entry label
`Left (`TextEntry (`id (`address), _("&Display as"), address)),
`VSpacing(0.2),
`ButtonBox(`PushButton(`id(`ok), `opt(`default, `key_F10), Label::OKButton()),
`PushButton(`id(`cancel), `opt (`key_F9), Label::CancelButton())),
`VSpacing(0.2)
),
`HSpacing(1)
);
UI::OpenDialog (`opt(`decorated), contents);
UI::ChangeWidget (`id (`user), `Value, user);
UI::SetFocus (`id (`user));
any ret = nil;
while (true)
{
ret = UI::UserInput ();
if (ret == `cancel)
{
break;
}
else if (ret == `ok)
{
// Input validation
user = (string) UI::QueryWidget (`id (`user), `Value);
address = (string) UI::QueryWidget (`id (`address), `Value);
if (!check_username (user))
{
UI::SetFocus (`id (`user));
Popup::Error (valid_username ());
}
else if (contains (forbidden, user))
{
UI::SetFocus (`id (`user));
// Translators: error message
Popup::Error (_("The address for this user is already defined."));
}
else if (!check_mail_address (address))
{
// string valid_mail_address
// no-spaces@valid_domainname
UI::SetFocus (`id (`address));
// error popup
Popup::Error (_("The mail address format is incorrect."));
}
else
{
// all checks OK, break the input loop
break;
}
}
}
UI::CloseDialog ();
return (ret == `ok)? $["comment": "", "user": user, "address": address] : $[];
}
/**
* D2.1
* @return `back, `abort or `next
*/
define symbol OutgoingDetailsDialog () ``{
Wizard::SetScreenShotName ("mail-2o-outgoing-details");
string mod = listToString (Mail::masquerade_other_domains);
list<string> lmod = [];
list<map> mu = Mail::masquerade_users;
// Translators: dialog caption
string caption = _("Masquerading");
term contents =
`VBox (
`VSpacing (0.2),
`RadioButtonGroup (
`id (`mdg),
`VBox (
`VSpacing (0.2),
WJ_MakeWidget (`from_header),
`VSpacing (0.2),
WJ_MakeWidget (`local_domains),
`VSpacing (0.2),
`Left (`RadioButton (
`id (`masqlocal),
// Translators: radio button label
_("Masquerade &local domains"),
mod == "")),
// `HBox (
// `HSpacing (2),
// `TextEntry (`id (`masqdomains), `opt (`disabled), _("That is"), ld)
//// `Left (`Label (`opt (`outputField, `hstretch), ld))
// ),
// Translators: radio button label
`Left (`RadioButton (`id (`masqothers), _("Ma&squerade other domains"), mod != "")),
`HBox (
`HSpacing (2),
// Translators: text entry label
`TextEntry (`id (`masqdomains), `opt (`notify), _("Do&mains to masquerade"), mod)
)
)
),
`VSpacing (1),
`Table (
`id (`tab),
`opt (`notify, `immediate),
// Translators: table column headings
`header (_("Local user"),
// Translators: table column headings
_("Display as")),
makeItems (mu, ["user", "address"])
),
/*
`HBox (
`HWeight (1, `ComboBox (`id (`user), `opt (`editable), _("Local user"),
["holly", "jane", "tarzan"])),
`HWeight (2, `TextEntry (`id (`address), _("Display as"), "holly@red.dwarf"))
),
*/
`HBox(
`PushButton(`id(`add), `opt (`key_F3), _("A&dd")),
`PushButton(`id(`edit), `opt (`key_F4), _("&Edit")),
`PushButton(`id(`delete), `opt (`key_F5), _("Dele&te"))
),
`VSpacing (1)
);
string help = WJ_MakeHelp ( [`from_header, `local_domains ]) +
MasqueradingDialogHelp ();
Wizard::SetContentsButtons (caption, contents, help , Label::BackButton (), Label::OKButton ());
symbol ret = nil;
edit_touched = false;
while (true)
{
boolean any_items = UI::QueryWidget (`id (`tab), `CurrentItem) != nil;
UI::ChangeWidget (`id (`edit), `Enabled, any_items);
UI::ChangeWidget (`id (`delete), `Enabled, any_items);
// Kludge, because a `Table still does not have a shortcut.
// watch out, a textentry sends UI too
if (ret != `masqdomains)
{
UI::SetFocus (`id (`tab));
}
ret = (symbol) UI::UserInput ();
if (ret == `cancel)
{
ret = `abort;
}
if (ret == `masqdomains)
{
UI::ChangeWidget (`id (`mdg), `CurrentButton, `masqothers);
}
else if (contains ([`add, `edit, `delete], ret))
{
mu = EditTable ((symbol)ret, mu, ["user", "address"],
MasqueradeUserPopup, `tab);
}
else if ((ret == `abort
&& Popup::ReallyAbort (Mail::touched || edit_touched))
|| ret == `back)
{
break;
}
else if (ret == `next)
{
// Input validation
// For consistency, all querywidgets are done here.
// The table contents is maintained and validated
// at the EditTable call.
symbol rb = (symbol) UI::QueryWidget (`id (`mdg), `CurrentButton);
if (rb == `masqothers)
{
mod = (string) UI::QueryWidget (`id (`masqdomains), `Value);
lmod = stringToList (mod);
}
else
{
lmod = [];
}
if (! Validate_from_header (`from_header))
{
y2debug ("nothing");
}
else if (! Validate_local_domains (`local_domains))
{
y2debug ("nothing, already done");
}
else if (find (string s, lmod, ``(! Hostname::CheckDomain (s))) != nil)
{
UI::SetFocus (`id (`masqdomains));
// Translators: error popup
// Already in Translation Memory
string msg = _("The domain name is incorrect");
// TODO: describe a valid domain name
Popup::Error (msg);
}
else
{
// all checks OK, break the input loop
break;
}
}
}
if (ret == `next)
{
// all querywidgets are already done by the validation part
Set_from_header (`from_header);
Set_local_domains (`local_domains);
Mail::Touch (Mail::masquerade_other_domains != lmod);
Mail::masquerade_other_domains = lmod;
Mail::Touch (Mail::masquerade_users != mu);
Mail::masquerade_users = mu;
}
Wizard::RestoreScreenShotName ();
return (symbol) ret;
}
/**
* D2.2
* Outgoing server authentification
* @return `back, `abort or `next
*/
define symbol OutgoingAuthOptions() ``{
Wizard::SetScreenShotName ("mail-2o-outgoing-authentication");
//string mod = listToString (Mail::masquerade_other_domains);
//list<string> lmod = [];
//list<map> mu = Mail::masquerade_users;
// Translators: dialog caption
string caption = _("Outgoing Server Authentication");
term contents =
`VBox(
`HBox(
`HWeight(1,
`Empty()
),
`HWeight(3,
`VBox(
// text entry
`TextEntry(`id(`server), _("Outgoing &Server")),
// text entry
`TextEntry(`id(`user), _("&User name")),
// password entry
`Password( `id(`passw), _("&Password"))
)
),
`HWeight(1,
`Empty()
)
)
);
//);
Wizard::SetContentsButtons (caption, contents, AuthenticationDialogHelp (), Label::BackButton (), Label::OKButton ());
any ret = nil;
map config = Mail::smtp_auth[0]:$[];
if (config == $[]) {
config = add(config, "server", Mail::outgoing_mail_server);
config = add(config, "user", "");
config = add(config, "password", "");
}
UI::ChangeWidget(`id(`server), `Value, config["server"]:"");
UI::ChangeWidget(`id(`user), `Value, config["user"]:"");
UI::ChangeWidget(`id(`passw), `Value, config["password"]:"");
while (true)
{
ret = UI::UserInput ();
if (ret == `cancel)
{
ret = `abort;