- Timestamp:
- 11/11/08 13:50:56 (8 weeks ago)
- Location:
- trunk/client
- Files:
-
- 7 modified
- 1 copied
-
printers (modified) (1 prop)
-
printers/ChangeLog (modified) (1 diff)
-
printers/migration/0002_support_external_printers.pl (copied) (copied from branches/juruen/fix-printers/printers/migration/0002_support_external_printers.pl)
-
printers/migration/Makefile.am (modified) (1 diff)
-
printers/src/EBox/Printers.pm (modified) (12 diffs)
-
printers/stubs/printers.conf.mas (modified) (2 diffs)
-
samba (modified) (1 prop)
-
samba/src/EBox/Samba.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/printers
-
Property
svn:mergeinfo set
to
/branches/juruen/fix-printers/printers:11548-11627
/branches/mailflogs/printers:11495-11498,11503
-
Property
svn:mergeinfo set
to
-
trunk/client/printers/ChangeLog
r11490 r11628 1 0.12. 992 + New release1 0.12.1 2 + Add support for external printers configured with CUPS 3 3 0.12 4 4 + Bugfix: Create the `job` table when installing. This readds a -
trunk/client/printers/migration/Makefile.am
r10308 r11628 3 3 Migrationsdir = @DATADIR@/ebox-printers/migration 4 4 5 nobase_Migrations_SCRIPTS = 0001_add_ipp_service.pl 5 nobase_Migrations_SCRIPTS = 0001_add_ipp_service.pl 0002_support_external_printers.pl 6 6 7 7 EXTRA_DIST = $(nobase_Migrations_SCRIPTS) -
trunk/client/printers/src/EBox/Printers.pm
r10308 r11628 37 37 use EBox::PrinterLogHelper; 38 38 use Foomatic::DB; 39 use HTML::Mason::Interp; 39 40 use Net::CUPS::Destination; 40 41 use Net::CUPS; … … 46 47 use constant CUPSD => '/etc/cups/cupsd.conf'; 47 48 use constant CUPSPPD => '/etc/cups/ppd/'; 48 49 use constant START_TAG => '# __EBOX__ TAG #'; 50 use constant END_TAG => '# END __EBOX__ TAG #'; 51 49 52 sub _create 50 53 { … … 166 169 } 167 170 168 sub _setCupsConf171 sub writeOldCupsConf 169 172 { 170 173 my $self = shift; … … 185 188 } 186 189 187 my @array; 188 push(@array, 'printers' => \@conf); 189 $self->writeConfFile(CUPSPRINTERS, 'printers/printers.conf.mas', \@array); 190 $self->writeConfFile(CUPSPRINTERS, 191 'printers/printers.conf.mas', 192 ['printers' => \@conf]); 193 194 } 195 196 sub _setCupsConf 197 { 198 my $self = shift; 199 200 $self->_mergeCupsConf(); 190 201 191 202 # Added configuration for standalone cups … … 195 206 @internalIfaces = @{$net->InternalIfaces()}; 196 207 } 197 @array = ( standaloneCups => $self->isStandaloneCupsEnabled(),208 my @array = ( standaloneCups => $self->isStandaloneCupsEnabled(), 198 209 ifaces => \@internalIfaces ); 199 210 $self->writeConfFile(CUPSD, 'printers/cupsd.conf.mas', \@array); … … 291 302 my $db = new Foomatic::DB; 292 303 my @makes = sort($db->get_makes()); 304 # Add Raw 305 push (@makes, 'Raw'); 293 306 return \@makes; 294 307 } … … 302 315 my $manufacturer = $self->manufacturer($id); 303 316 my @models = sort ($db->get_models_by_make($manufacturer)); 317 push (@models, 'Raw'); 304 318 return \@models; 305 319 } … … 327 341 my $maker = $self->manufacturer($id); 328 342 my $model = $self->model($id); 343 if ($maker eq 'Raw') { 344 return 'Raw'; 345 } 329 346 my $db = new Foomatic::DB; 330 347 return $db->get_printer_from_make_model($maker, $model); … … 337 354 338 355 my $printer = $self->_printerIdDriver($id); 339 356 if ($printer eq 'Raw') { 357 return ['Raw']; 358 } 340 359 my $db = new Foomatic::DB; 341 my @drivers = grep(! /^(gimp.*)|(hpdj)/,342 $db->get_drivers_for_printer($printer));360 #my @drivers = grep(! /^(gimp.*)|(hpdj)/, 361 my @drivers = $db->get_drivers_for_printer($printer); 343 362 if (@drivers) { 344 363 return \@drivers; … … 921 940 922 941 my $printerid = $self->_printerFromManuModel($manufacturer, $printer); 923 $printerid or return {};942 $printerid or return []; 924 943 925 944 my $db = new Foomatic::DB; 926 945 my $dat = $db->getdat($driver, $printerid); 927 946 928 my @args = keys %{$dat->{args_byname}}; 929 return \@args; 947 return [ keys %{$dat->{args_byname}} ]; 930 948 } 931 949 … … 1092 1110 1093 1111 my $printer = $self->model($id); 1112 if ($printer eq 'Raw') { 1113 return; 1114 } 1094 1115 my $manufacturer = $self->manufacturer($id); 1095 1116 my $driver = $self->driver($id); … … 1300 1321 } 1301 1322 1323 sub _mergeCupsConf 1324 { 1325 my ($self) = @_; 1326 1327 my $manager = new EBox::ServiceModule::Manager(); 1328 if ($manager->checkUserModifications() 1329 and $manager->skipModification( 1330 $self->serviceModuleName(), CUPSPRINTERS)) { 1331 EBox::info('Skipping modification of ' . CUPSPRINTERS); 1332 #return; 1333 } 1334 1335 my %external = map {$_ => 1} @{$self->fetchExternalCUPSPrinters}; 1336 my @file; 1337 if ( -f CUPSPRINTERS ) { 1338 my $cmd = 'cat ' . CUPSPRINTERS; 1339 @file = @{root($cmd)}; 1340 } 1341 my $startTag = START_TAG; 1342 my $endTag = END_TAG; 1343 1344 my @newFile; 1345 my $copy = 1; 1346 for my $line (@file) { 1347 if ($line =~ /$startTag/) { 1348 $copy = undef; 1349 } 1350 push (@newFile, $line) if ($copy); 1351 if ((not $copy) and $line =~ /$endTag/) { 1352 $copy = 1; 1353 } 1354 } 1355 1356 my $output; 1357 1358 my $interp = HTML::Mason::Interp->new(comp_root => 1359 EBox::Config::stubs, 1360 out_method => \$output); 1361 my $comp = $interp->make_component( 1362 comp_file => 1363 EBox::Config::stubs() . 'printers/printers.conf.mas'); 1364 my @conf; 1365 my @idprinters = $self->all_dirs("printers"); 1366 for my $dirid (@idprinters){ 1367 my $id = $dirid; 1368 $id =~ s'.*/''; 1369 unless ($self->_printerConfigured($id)){ 1370 $self->removePrinter($id); 1371 next; 1372 } 1373 $self->_setDriverOptionsToFile($id); 1374 my $printer = $self->_printerInfo($id); 1375 next if (exists $external{$printer->{name}}); 1376 $printer->{location} = $self->_location($id); 1377 push (@conf, $printer ); 1378 } 1379 1380 1381 $interp->exec($comp, 'printers' => \@conf); 1382 1383 push (@newFile, $output); 1384 1385 my $file = EBox::Config::tmp() . '/printers.conf.tmp'; 1386 open (my $fd, ">$file"); 1387 print $fd @newFile; 1388 root("cp $file " . CUPSPRINTERS); 1389 close ($fd); 1390 1391 $manager->updateFileDigest($self->serviceModuleName(), CUPSPRINTERS); 1392 } 1393 1394 # Method: fetchExternalCUPSPrinters 1395 # 1396 # This method returns those printers that haven been configured 1397 # by the user using CUPS and not our interface. 1398 # 1399 # Returns: 1400 # 1401 # Array ref - containing the printer names 1402 # 1403 sub fetchExternalCUPSPrinters 1404 { 1405 my ($self) = @_; 1406 1407 my %eboxPrinters = map { $_->{name} => 1 } @{$self->printers()}; 1408 1409 my $cups = Net::CUPS->new(); 1410 1411 my @printers; 1412 foreach my $printer ($cups->getDestinations()) 1413 { 1414 my $name = $printer->getName(); 1415 push (@printers, $name) unless (exists $eboxPrinters{$name}); 1416 } 1417 return \@printers; 1418 } 1419 1420 1302 1421 # Method: enableStandaloneCups 1303 1422 # -
trunk/client/printers/stubs/printers.conf.mas
r10308 r11628 4 4 <%init> 5 5 use EBox::Gettext; 6 use EBox::Printers; 6 7 </%init> 7 8 <% EBox::Printers::START_TAG %> 8 9 % foreach my $printer (@printers) { 9 10 <Printer <% $printer->{name} %>> … … 19 20 </Printer> 20 21 % } 22 <% EBox::Printers::END_TAG %> -
trunk/client/samba
- Property svn:mergeinfo set to /branches/juruen/fix-printers/samba:11548-11627
-
trunk/client/samba/src/EBox/Samba.pm
r11511 r11628 718 718 } 719 719 else { 720 EBox::error("The user has incomplete group memberships; to be administrator he must be both member of domain Admins and Administrators group"); 721 return undef; 720 EBox::error("The user has incomplete group memberships; to be administrator he must be both member of domain Admins and Administrators group"); 721 return undef; 722 722 } 723 723 } … … 882 882 $self->set_list("printers/$name/users", "string", []); 883 883 $self->set_list("printers/$name/groups", "string", []); 884 884 $self->set_bool("printers/external", undef); 885 886 } 887 888 sub _addExternalPrinter 889 { 890 my ($self, $name) = @_; 891 $self->set_list("printers/$name/users", "string", []); 892 $self->set_list("printers/$name/groups", "string", []); 893 $self->set_bool("printers/$name/external", 1); 885 894 } 886 895 … … 889 898 my $self = shift; 890 899 900 my $printers = EBox::Global->modInstance('printers'); 901 my %external = map { $_ => 1 } @{$printers->fetchExternalCUPSPrinters()}; 891 902 my @printers; 903 my $readOnly = $self->isReadOnly(); 892 904 for my $printer (@{$self->array_from_dir("printers")}) { 905 my $name = $printer->{_dir}; 906 my $key = "printers/$name/external"; 907 my $isExt = $self->get_bool($key); 908 if ($isExt and not exists $external{$name}) { 909 $self->delPrinter($name) unless ($readOnly); 910 $external{$name} = 'removed'; 911 } elsif ($isExt) { 912 $external{$name} = 'exists'; 913 } 893 914 push (@printers, $printer->{'_dir'}); 894 915 } 895 916 896 return \@printers; 917 unless ($readOnly) { 918 for my $newPrinter (grep { $external{$_} == 1 } keys %external) { 919 $self->_addExternalPrinter($newPrinter); 920 push (@printers, $newPrinter); 921 } 922 } 923 924 return [sort @printers]; 897 925 } 898 926 … … 970 998 971 999 my @printers; 972 for my $printer (@{$self->array_from_dir("printers")}) { 973 my $name = $printer->{'_dir'}; 1000 for my $name (@{$self->printers()}) { 974 1001 my $print = { 'name' => $name, 'allowed' => undef }; 975 my $users = $ printer->{'users'};1002 my $users = $self->get_list("printers/$name/users"); 976 1003 if (@{$users}) { 977 1004 $print->{'allowed'} = 1 if (grep(/^$user$/, @{$users}));
