2 # Functions for webmin print and smb drivers.
3 # Very similar to the webmin driver, but with a different interface
6 $webmin_windows_driver = 1;
7 $webmin_print_driver = 1;
9 # is_windows_driver(path)
10 # Returns a driver structure if some path is a windows driver
13 return &is_webmin_windows_driver(@_);
17 # Returns a structure containing the details of a driver
20 return &is_webmin_driver(@_);
23 # create_windows_driver(&printer, &driver)
24 # Creates a new windows printer driver
25 sub create_windows_driver
27 return &create_webmin_windows_driver(@_);
30 # create_driver(&printer, &driver)
31 # Creates a new local printer driver and returns the path
34 return &create_webmin_driver(@_);
40 &delete_webmin_driver(@_);
43 # driver_input(&printer, &driver)
46 local ($prn, $drv) = @_;
48 printf "<tr> <td><input type=radio name=drv value=0 %s> %s</td>\n",
49 $drv->{'mode'} == 0 ? "checked" : "", $text{'webmin_none'};
50 print "<td>($text{'webmin_remotemsg'})</td> </tr>\n";
52 printf "<tr> <td><input type=radio name=drv value=2 %s> %s</td>\n",
53 $drv->{'mode'} == 2 ? "checked" : "", $text{'webmin_model'};
54 print "<td><select name=iface>\n";
55 opendir(DIR, $config{'model_path'});
56 while($f = readdir(DIR)) {
57 if ($f =~ /^\./) { next; }
58 $path = "$config{'model_path'}/$f";
59 printf "<option value=\"$path\" %s>$f\n",
60 $path eq $prn{'iface'} ? "selected" : "";
63 print "</select></td> </tr>\n";
65 if (&has_ghostscript()) {
66 local $out = &backquote_command("$config{'gs_path'} -help 2>&1", 1);
67 if ($out =~ /Available devices:\n((\s+.*\n)+)/) {
68 print "<tr> <td valign=top>\n";
69 printf "<input type=radio name=drv value=1 %s>\n",
70 $drv->{'mode'} == 1 ? "checked" : "";
71 print "$text{'webmin_driver'}</td> <td valign=top>";
72 foreach $d (split(/\s+/, $1)) { $drvsupp{$d}++; }
73 print "<select name=driver size=7>\n";
74 foreach $d (&list_webmin_drivers()) {
75 if ($drvsupp{$d->[0]}) {
76 printf "<option %s>%s\n",
77 $d->[1] eq $drv->{'type'} ? "selected" : "",
81 print "</select> ";
82 print "<select name=dpi size=7>\n";
83 printf "<option value=\"\" %s>Default\n",
84 $drv->{'dpi'} ? "" : "selected";
85 foreach $d (75, 100, 150, 200, 300, 600) {
86 printf "<option value=\"$d\" %s>$d DPI\n",
87 $drv->{'dpi'} == $d ? "selected" : "";
89 print "</select></td> </tr>\n";
92 print "<tr> <td colspan=2>",
93 &text('webmin_edrivers', "<tt>$config{'gs_path'}</tt>"),
98 print "<tr> <td colspan=2>",
99 &text('webmin_egs', "<tt>$config{'gs_path'}</tt>"),
106 # Parse driver selection from %in and return a driver structure
109 if ($in{'drv'} == 0) {
110 return { 'mode' => 0 };
112 elsif ($in{'drv'} == 2) {
113 (-x $in{'iface'}) || &error("'$in{'iface'}' does not exist");
114 return { 'mode' => 2,
115 'program' => $in{'iface'} };
117 elsif ($in{'drv'} == 1) {
118 return { 'mode' => 1,
119 'type' => $in{'driver'},
120 'dpi' => $in{'dpi'} };