Author: mzugec Date: Fri Feb 6 15:51:32 2009 New Revision: 55311 URL: http://svn.opensuse.org/viewcvs/yast?rev=55311&view=rev Log: AutoYaST support (bnc#464364) - export only Added: trunk/printer/agents/ trunk/printer/agents/Makefile.am trunk/printer/agents/ag_cups (with props) trunk/printer/agents/cfg_cups.scr Modified: trunk/printer/VERSION trunk/printer/package/yast2-printer.changes trunk/printer/src/Printer.ycp trunk/printer/src/Printerlib.ycp trunk/printer/src/printer.desktop trunk/printer/src/printer_auto.ycp Modified: trunk/printer/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/VERSION?rev=55311&r1=55310&r2=55311&view=diff ============================================================================== --- trunk/printer/VERSION (original) +++ trunk/printer/VERSION Fri Feb 6 15:51:32 2009 @@ -1 +1 @@ -2.18.0 +2.18.1 Added: trunk/printer/agents/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/agents/Makefile.am?rev=55311&view=auto ============================================================================== --- trunk/printer/agents/Makefile.am (added) +++ trunk/printer/agents/Makefile.am Fri Feb 6 15:51:32 2009 @@ -0,0 +1,5 @@ +agent_SCRIPTS = ag_cups + +scrconf_DATA = cfg_cups.scr + +EXTRA_DIST = $(agent_SCRIPTS) $(scrconf_DATA) Added: trunk/printer/agents/ag_cups URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/agents/ag_cups?rev=55311&view=auto ============================================================================== --- trunk/printer/agents/ag_cups (added) +++ trunk/printer/agents/ag_cups Fri Feb 6 15:51:32 2009 @@ -0,0 +1,173 @@ +#!/usr/bin/perl -w +package ag_cups_server; +BEGIN { push( @INC, '/usr/share/YaST2/modules/' ); } +use ycp; +use YaST::SCRAgent; +use YaPI; +textdomain "printer"; +our @ISA = ("YaST::SCRAgent"); +use strict; + + use Data::Dumper; + + + +sub createOrInsert { + my ($line, $data_ref) = @_; + if ( $line=~/(\w*)\s+([\w\W]*)/){ + # add to existing list + if (exists $$data_ref{$1}){ + push(@{$$data_ref{$1}}, $2); + # new item + } else{ + $$data_ref{$1}=[$2]; + } + } +} + +sub createOrInsertSection { + my ($line, $section, $data_ref) = @_; + foreach (@$data_ref){ + if($$section eq "$_->{'Key'} $_->{'Value'}"){ + createOrInsert($line, $_); + } + } +} + +sub parseSection{ + my ($sec_r, $line, $data_r) = @_; + #new section + if ($line =~ /<([\w]*)\s*([\w\W]*)>/){ + push(@$sec_r, "$1 $2"); + + if(scalar @$sec_r==2){ + my $pos=0; + foreach (@{$$data_r{'sections'}}){ + if(@$sec_r[0] eq "$_->{'Key'} $_->{'Value'}"){ + @{$$data_r{'sections'}[$pos]{'sections'}}=() if (!exists $$data_r{'sections'}[$pos]{'sections'}); + $data_r=$$data_r{'sections'}[$pos]; + } + $pos++; + } + } + + $$data_r{'sections'}=[] if(!exists $$data_r{'sections'}); + push(@{$$data_r{'sections'}}, {'Key'=>$1, 'Value'=>$2}); + + } else{ + # global section only + if (scalar @$sec_r==0 or @$sec_r[0] eq ""){ + createOrInsert($line, \%$data_r); + #inside sections + }else{ + my $ref = \@{$$data_r{'sections'}}; + # in case of sub-section ... + if(scalar @$sec_r==2){ + my $pos=0; + foreach (@{$$data_r{'sections'}}){ + if(@$sec_r[0] eq "$_->{'Key'} $_->{'Value'}"){ + $ref=\@{$$data_r{'sections'}[$pos]{'sections'}}; + } + $pos++; + } + } + createOrInsertSection($line, \@$sec_r[scalar @$sec_r-1], $ref); + } + } +} + +sub parse_conf { +# my $class = shift; + my $file = shift; + + my %data=(); + my @section=(); + if( open( FILE, $file ) ) { + while( my $line = <FILE> ) { + chomp($line); + # remove comments + next if ( $line =~ /^\s*#/ || $line =~ /^\s*$/); + + # end of the section + if($line=~/<\/([\w\W]*)>/){ + pop(@section); + } else{ + parseSection(\@section, $line, \%data); + } + } + close(FILE); + } + return \%data; +} + +sub Execute { + my $class = shift; + my ($path, @args) = @_; + + return 1; +} + +sub write_conf { + my ($file, $data_r) = @_; +$file=">/tmp/agent.log"; +my $data=@$data_r[0]; + +open( WRT, $file ); +foreach my $key(keys %$data){ + foreach my $options ($$data{$key}){ + if ($key eq "sections"){ + print WRT Dumper($options); + }else{ + foreach my $params (@$options){ + print WRT "$key $params\n"; + } + } + } +} +close(WRT); + return 1; +} + +sub Read { + my $class = shift; + my ($path, @args) = @_; + my $server = "< /etc/cups/cupsd.conf"; + my $client = "< /etc/cups/client.conf"; + + if ($path eq ".server"){ + return parse_conf($server); + } + elsif ($path eq ".client"){ + return parse_conf($client); + } + elsif ($path eq "."){ + return [('server'=> parse_conf($server), 'client'=>parse_conf($client))]; + }else{ + #not implemented + } +} + +sub Write { + my $class = shift; + my ($path, @args) = @_; + my $server = "< /etc/cups/cupsd.conf"; + my $client = "< /etc/cups/client.conf"; + + if ($path eq ".client"){ + return write_conf($client, $args[0]); + } + elsif ($path eq ".server"){ + return write_conf($server, $args[0]); + } + else{ + #not implemented + } +} + +sub Dir { +} + +package main; + +ag_cups_server->Run (); + Added: trunk/printer/agents/cfg_cups.scr URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/agents/cfg_cups.scr?rev=55311&view=auto ============================================================================== --- trunk/printer/agents/cfg_cups.scr (added) +++ trunk/printer/agents/cfg_cups.scr Fri Feb 6 15:51:32 2009 @@ -0,0 +1,19 @@ +/** + * File: + * tty.scr + * Summary: + * SCR Agent for reading/writing CUPS configuration + * Access: + * read/write + * Authors: + * See: + * anyagent + * libscr + * Example: + + * $Id: cfg_icups_server.scr 14516 2009-01-20 16:34:50Z mzugec $ + * + */ +.cups + +`ag_cups () Modified: trunk/printer/package/yast2-printer.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/package/yast2-printer.changes?rev=55311&r1=55310&r2=55311&view=diff ============================================================================== --- trunk/printer/package/yast2-printer.changes (original) +++ trunk/printer/package/yast2-printer.changes Fri Feb 6 15:51:32 2009 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Fri Feb 6 15:48:53 CET 2009 - mzugec@suse.cz + +- AutoYaST support (bnc#464364) - export only +- 2.18.1 + +------------------------------------------------------------------- Mon Jan 26 16:59:45 CET 2009 - mzugec@suse.cz - marked string for translation (bnc#459414) Modified: trunk/printer/src/Printer.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printer.ycp?rev=55311&r1=55310&r2=55311&view=diff ============================================================================== --- trunk/printer/src/Printer.ycp (original) +++ trunk/printer/src/Printer.ycp Fri Feb 6 15:51:32 2009 @@ -2063,7 +2063,9 @@ * @return boolean True on success */ global boolean Import (map settings) { - // TODO FIXME: your code here (fill the above mentioned variables)... +y2internal("Import : %1", settings); +// Printerlib::client_conf_server_name = settings["cups_remote_server"]:""; +// Printerlib::WriteCupsSettings(settings["server_settings"]:$[]); return true; } @@ -2073,8 +2075,17 @@ * @return map Dumped settings (later acceptable by Import ()) */ global map Export () { - // TODO FIXME: your code here (return the above mentioned variables)... - return $[]; + Printerlib::DetermineClientOnly(); + Printer::AutodetectQueues(); + list <map> p_queues = filter(map queue, Printer::queues, { return (queue["config"]:""=="local"); }); + map exp = $[ +// "queues" : p_queues, +// "filters" : Printerlib::ExportFilters( p_queues ), + "server_settings" : (map)SCR::Read(.cups.server), + "cups_remote_server" : (map)SCR::Read(.cups.client) + ]; +//y2internal("export %1", exp); + return exp; } /** Modified: trunk/printer/src/Printerlib.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printerlib.ycp?rev=55311&r1=55310&r2=55311&view=diff ============================================================================== --- trunk/printer/src/Printerlib.ycp (original) +++ trunk/printer/src/Printerlib.ycp Fri Feb 6 15:51:32 2009 @@ -36,7 +36,7 @@ import "Package"; import "Popup"; import "Service"; - +import "Map"; // Fortunately the tools are for all architectures always // installed in /usr/lib/YaST2/bin/ (i.e. no "lib64"). // I tested this on Thu Aug 28 2008 using the command Modified: trunk/printer/src/printer.desktop URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printer.desktop?rev=55311&r1=55310&r2=55311&view=diff ============================================================================== --- trunk/printer/src/printer.desktop (original) +++ trunk/printer/src/printer.desktop Fri Feb 6 15:51:32 2009 @@ -11,10 +11,11 @@ X-SuSE-YaST-Group=Hardware X-SuSE-YaST-Argument= X-SuSE-YaST-RootOnly=true -X-SuSE-YaST-AutoInst= +X-SuSE-YaST-AutoInst=all X-SuSE-YaST-Geometry= X-SuSE-YaST-SortKey= X-SuSE-YaST-AutoInstResource=printer +X-SuSE-YaST-AutoInstClonable=true Icon=yast-printer Exec=/sbin/yast2 printer Modified: trunk/printer/src/printer_auto.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printer_auto.ycp?rev=55311&r1=55310&r2=55311&view=diff ============================================================================== --- trunk/printer/src/printer_auto.ycp (original) +++ trunk/printer/src/printer_auto.ycp Fri Feb 6 15:51:32 2009 @@ -71,6 +71,10 @@ Printer::Import($[]); ret = $[]; } +// TODO: use global value to set Printer::dirty +else if (func == "GetModified") { + ret = true; + } /* Change configuration (run AutoSequence) */ else if (func == "Change") { ret = PrinterAutoSequence(); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org