Author: jsuchome Date: Fri Jul 27 16:13:09 2007 New Revision: 39749 URL: http://svn.opensuse.org/viewcvs/yast?rev=39749&view=rev Log: first module scatch, WIP Removed: trunk/fingerprint-reader/src/complex.ycp Modified: trunk/fingerprint-reader/src/FingerprintReader.ycp trunk/fingerprint-reader/src/Makefile.am trunk/fingerprint-reader/src/dialogs.ycp trunk/fingerprint-reader/src/wizards.ycp Modified: trunk/fingerprint-reader/src/FingerprintReader.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/fingerprint-reader/src/FingerprintReader.ycp?rev=39749&r1=39748&r2=39749&view=diff ============================================================================== --- trunk/fingerprint-reader/src/FingerprintReader.ycp (original) +++ trunk/fingerprint-reader/src/FingerprintReader.ycp Fri Jul 27 16:13:09 2007 @@ -35,15 +35,11 @@ module "FingerprintReader"; textdomain "fingerprint-reader"; +import "Pam"; +import "Popup"; import "Progress"; import "Report"; import "Summary"; -import "Message"; - -/** - * Prototypes - */ -global boolean Modified(); /** * Data was modified? @@ -51,8 +47,10 @@ global boolean modified = false; /** + * Required packages for this module to operate + * FIXME UpdatedArchPackages ??? */ -global boolean proposal_valid = false; +global list<string> required_packages = ["pam_thinkfinger"]; /** * Write only, used during autoinstallation. @@ -61,46 +59,30 @@ global boolean write_only = false; /** - * Abort function - * return boolean return true if abort + * if Fingerprint Reader authentication is enabled */ -global boolean() AbortFunction = Modified; +global boolean use_pam = false; /** - * Abort function - * @return boolean return true if abort + * Directory with fingerprint files that should be imported */ -global define boolean Abort() ``{ - if(AbortFunction != nil) - { - return AbortFunction () == true; - } - return false; -} +global string import_dir = ""; /** - * Data was modified? - * @return true if modified + * Directory for storing fingerprint files + */ +string bir_dir = "/etc/pam_thinkfinger"; + +/** + * Get the list of fingerprint readers */ -global boolean Modified() { - y2debug("modified=%1",modified); - return modified; -} - -// Settings: Define all variables needed for configuration of fingerprint-reader -// TODO FIXME: Define all the variables necessary to hold -// TODO FIXME: the configuration here (with the appropriate -// TODO FIXME: description) -// TODO FIXME: For example: -// /** -// * List of the configured cards. -// */ -// list cards = []; -// -// /** -// * Some additional parameter needed for the configuration. -// */ -// boolean additional_parameter = true; +global list ReadFingerprintReaderDevices () { + + list devices = (list) SCR::Read (.probe.fingerprint); + if (devices == nil) + devices = []; + return devices; +} /** * Read all fingerprint-reader settings @@ -108,71 +90,17 @@ */ global boolean Read() { - /* FingerprintReader read dialog caption */ - string caption = _("Initializing fingerprint-reader Configuration"); + list devices = ReadFingerprintReaderDevices (); - // TODO FIXME Set the right number of stages - integer steps = 4; - - integer sl = 500; - sleep(sl); - - // TODO FIXME Names of real stages - // We do not set help text here, because it was set outside - Progress::New( caption, " ", steps, [ - /* Progress stage 1/3 */ - _("Read the database"), - /* Progress stage 2/3 */ - _("Read the previous settings"), - /* Progress stage 3/3 */ - _("Detect the devices") - ], [ - /* Progress step 1/3 */ - _("Reading the database..."), - /* Progress step 2/3 */ - _("Reading the previous settings..."), - /* Progress step 3/3 */ - _("Detecting the devices..."), - /* Progress finished */ - _("Finished") - ], - "" - ); - - // read database - if(Abort()) return false; - Progress::NextStage(); - /* Error message */ - if(false) Report::Error(_("Cannot read database1.")); - sleep(sl); - - // read another database - if(Abort()) return false; - Progress::NextStep(); - /* Error message */ - if(false) Report::Error(_("Cannot read database2.")); - sleep(sl); - - // read current settings - if(Abort()) return false; - Progress::NextStage(); - /* Error message */ - if(false) Report::Error(Message::CannotReadCurrentSettings()); - sleep(sl); - - // detect devices - if(Abort()) return false; - Progress::NextStage(); - /* Error message */ - if(false) Report::Warning(_("Cannot detect devices.")); - sleep(sl); + if (devices == []) + { + // error popup: no config of non-existent device + Report::Error (_("Fingerprint reader device is not available on this system.")); +// return false; + } - if(Abort()) return false; - /* Progress finished */ - Progress::NextStage(); - sleep(sl); + use_pam = Pam::Enabled ("thinkfinger"); - if(Abort()) return false; modified = false; return true; } @@ -183,53 +111,58 @@ */ global boolean Write() { - /* FingerprintReader read dialog caption */ - string caption = _("Saving fingerprint-reader Configuration"); + if (!modified) + return true; - // TODO FIXME And set the right number of stages - integer steps = 2; + // FingerprintReader read dialog captio + string caption = _("Saving Fingerprint Reader Configuration"); - integer sl = 500; + integer sl = 100; sleep(sl); - // TODO FIXME Names of real stages // We do not set help text here, because it was set outside - Progress::New(caption, " ", steps, [ - /* Progress stage 1/2 */ - _("Write the settings"), - /* Progress stage 2/2 */ - _("Run SuSEconfig") + Progress::New(caption, " ", 2, [ + // Progress stage + _("Write the PAM settings"), + // Progress stage + _("Import fingerprint files"), ], [ - /* Progress step 1/2 */ - _("Writing the settings..."), - /* Progress step 2/2 */ - _("Running SuSEconfig..."), - /* Progress finished */ + // Progress step + _("Writing the PAM settings..."), + // Progress step + _("Importing fingerprint files..."), + // Progress finished _("Finished") ], "" ); - // write settings - if(Abort()) return false; Progress::NextStage(); - /* Error message */ - if(false) Report::Error (_("Cannot write settings.")); - sleep(sl); - // run SuSEconfig - if(Abort()) return false; - Progress::NextStage (); - /* Error message */ - if(false) Report::Error (Message::SuSEConfigFailed()); + boolean pam_ret = use_pam ? + Pam::Add ("thinkfinger") : Pam::Remove ("thinkfinger"); + if (!pam_ret) + // Error message + Report::Error (_("Cannot write PAM settings.")); + sleep(sl); - if(Abort()) return false; - /* Progress finished */ + Progress::NextStage(); + if (use_pam && import_dir != "") + { + map out = (map) SCR::Execute (.target.bash_output, + sformat ("/bin/cp %1/*.bir %2/", import_dir, bir_dir)); + if (out["stderr"]:"" != "") + { + // error popup + Popup::ErrorDetails (_("Importing fingerprint files failed."), + out["stderr"]:""); + } + } + Progress::NextStage(); sleep(sl); - if(Abort()) return false; return true; } @@ -240,7 +173,9 @@ * @return boolean True on success */ global boolean Import (map settings) { - // TODO FIXME: your code here (fill the above mentioned variables)... + + use_pam = settings["use_pam"]:use_pam; + import_dir = settings["import_dir"]:import_dir; return true; } @@ -250,8 +185,10 @@ * @return map Dumped settings (later acceptable by Import ()) */ global map Export () { - // TODO FIXME: your code here (return the above mentioned variables)... - return $[]; + return $[ + "use_pam" : use_pam, + "import_dir" : import_dir + ]; } /** @@ -259,18 +196,31 @@ * @return summary of the current configuration */ global list Summary() { - // TODO FIXME: your code here... - /* Configuration summary text for autoyast */ - return [ _("Configuration summary..."), [] ]; + + // summary header + string summary = Summary::AddHeader(summary, _("PAM Login")); + + summary = Summary::AddLine (summary, (use_pam) ? + // summary item + _("Use Fingerprint Authentication") : + // summary item + _("Do Not Use Fingerprint Authentication")); + return [ summary, [] ]; } /** - * Create an overview table with all configured cards - * @return table items + * Create a short textual summary + * @return summary of the current configuration */ -global list Overview() { - // TODO FIXME: your code here... - return []; +global define string ShortSummary() { + + return sformat ( + // summary text (yes/no follows) + _("<b>Fingerprint Authentication Enabled</b>: %1<br>"), use_pam ? + // summary value + _("Yes") : + // summary value + _("No")); } /** @@ -280,8 +230,7 @@ * @return map with 2 lists. */ global map AutoPackages() { - // TODO FIXME: your code here... - return $[ "install":[], "remove":[] ]; + return $[ "install": required_packages, "remove":[] ]; } /* EOF */ Modified: trunk/fingerprint-reader/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/fingerprint-reader/src/Makefile.am?rev=39749&r1=39748&r2=39749&view=diff ============================================================================== --- trunk/fingerprint-reader/src/Makefile.am (original) +++ trunk/fingerprint-reader/src/Makefile.am Fri Jul 27 16:13:09 2007 @@ -7,10 +7,9 @@ users_plugin_fingerprint_reader.ycp ynclude_DATA = \ - helps.ycp \ wizards.ycp \ dialogs.ycp \ - complex.ycp + helps.ycp desktop_DATA = \ fingerprint-reader.desktop Modified: trunk/fingerprint-reader/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/fingerprint-reader/src/dialogs.ycp?rev=39749&r1=39748&r2=39749&view=diff ============================================================================== --- trunk/fingerprint-reader/src/dialogs.ycp (original) +++ trunk/fingerprint-reader/src/dialogs.ycp Fri Jul 27 16:13:09 2007 @@ -31,85 +31,151 @@ textdomain "fingerprint-reader"; +import "Confirm"; +import "FileUtils"; +import "FingerprintReader"; import "Label"; +import "Popup"; +import "Stage"; import "Wizard"; -import "FingerprintReader"; include "fingerprint-reader/helps.ycp"; +boolean ReallyAbort() { + return !FingerprintReader::modified || Popup::ReallyAbort(true); +} + /** - * Configure1 dialog - * @return dialog result + * Read settings dialog + * @return `abort if aborted and `next otherwise */ -any Configure1Dialog () { - - /* FingerprintReader configure1 dialog caption */ - string caption = _("FingerprintReader Configuration"); - - /* FingerprintReader configure1 dialog contents */ - term contents = `Label (_("First part of configuration of fingerprint-reader")); - - Wizard::SetContentsButtons(caption, contents, HELPS["c1"]:"", - Label::BackButton(), Label::NextButton()); - - any ret = nil; - while(true) { - - ret = UI::UserInput(); - - /* abort? */ - if(ret == `abort || ret == `cancel) { - if(ReallyAbort()) break; - else continue; - } - else if(ret == `next || ret == `back) { - break; - } - else { - y2error("unexpected retcode: %1", ret); - continue; - } - } +symbol ReadDialog() { + Wizard::RestoreHelp(HELPS["read"]:""); + if (!Confirm::MustBeRoot()) return `abort; + boolean ret = FingerprintReader::Read(); + return ret ? `next : `abort; +} - return ret; +/** + * Write settings dialog + * @return `abort if aborted and `next otherwise + */ +symbol WriteDialog() { + Wizard::RestoreHelp(HELPS["write"]:""); + boolean ret = FingerprintReader::Write(); + return ret ? `next : `abort; } /** - * Configure2 dialog + * Main configuration dialog * @return dialog result */ -any Configure2Dialog () { +any FingerprintReaderDialog() { - /* FingerprintReader configure2 dialog caption */ - string caption = _("FingerprintReader Configuration"); + // FingerprintReader summary dialog caption + string caption = _("Fingerprint Reader Configuration"); - /* FingerprintReader configure2 dialog contents */ - term contents = `Label (_("Second part of configuration of fingerprint-reader")); + boolean use_pam = FingerprintReader::use_pam; + // help text + string help_text = _("<p> +<b><big>Fingerprint Authentication</big></b><br> +The Fingerprint Reader configuration updates your PAM settings to enable authentication with fingerprints.</p>") + + + // help text, cont. + _("<p>To <b>import fingerprint files</b> from different system or previous installation, choose the directory with their location.</p>"); + + term con = `HBox (`HSpacing (3), `VBox ( + // frame label + `Frame (_("User Authentication"), `HBox(`HSpacing (0.5), `VBox( + `VSpacing (0.5), + `RadioButtonGroup (`id(`rd), + `Left (`HVSquash(`VBox ( + `Left (`RadioButton (`id(`pamno), `opt (`notify), + // radio button label + _("Do No&t Use Fingerprint Reader"), !use_pam)), + `Left (`RadioButton (`id(`pamyes), `opt (`notify), + // radio button label + _("&Use Fingerprint Reader"), use_pam)) + ))) + ), + `VSpacing (0.5) + ), `HSpacing (0.5))), + `VSpacing (), + `HBox ( + // textentry label + `TextEntry (`id(`import_dir),_("Directory with fingerprint files")), + `VBox ( + `Label (""), + `PushButton (`id (`browse), Label::BrowseButton ()) + ) + ) + ), `HSpacing(3)); + + Wizard::SetContentsButtons (caption, con, help_text, + Stage::cont () ? Label::BackButton () : Label::CancelButton (), + Stage::cont () ? Label::NextButton () : Label::FinishButton () + ); + if (!Stage::cont ()) + Wizard::HideAbortButton (); - Wizard::SetContentsButtons(caption, contents, HELPS["c2"]:"", - Label::BackButton(), Label::NextButton()); + UI::ChangeWidget (`id (`import_dir), `Enabled, use_pam); any ret = nil; - while(true) { + while (true) { ret = UI::UserInput(); + string import_dir = (string)UI::QueryWidget (`id (`import_dir), `Value); + + if (ret == `pamyes || result == `pamno) + { + use_pam = (ret == `pamyes); + UI::ChangeWidget (`id (`import_dir), `Enabled, use_pam); + } - /* abort? */ - if(ret == `abort || ret == `cancel) { + if (ret == `abort || ret == `cancel || ret == `back) { if(ReallyAbort()) break; else continue; } - else if(ret == `next || ret == `back) { + else if (ret == `browse) { + string dir = UI::AskForExistingDirectory (import_dir, ""); + if (dir != nil) + { + if ((findlastof (dir, "/") + 1) == size(dir)) + dir = substring (dir, 0, size(dir)-1); + UI::ChangeWidget (`id(`home), `Value, dir); + } + } + else if (ret == `next) { + if (use_pam && import_dir != "" && + !FileUtils::IsDirectory (import_dir)) + { + // error popup + Report::Error (_("The path to fingerprint files +does not point to the valid directory.")); + UI::SetFocus (`id (`import_dir)); + continue; + } + if (use_pam && + !Package::InstallAll (FingerprintReader::required_packages)) + { + use_pam = false; + UI::ChangeWidget (`id (`rd), `Value, `pamno); + UI::ChangeWidget (`id (`import_dir), `Enabled, use_pam); + continue; + } + if (use_pam != FingerprintReader::use_pam || + (use_pam && import_dir != "")) + { + FingerprintReader::modified = true; + FingerprintReader::use_pam = use_pam; + FingerprintReader::import_dir = import_dir; + } break; } - else { - y2error("unexpected retcode: %1", ret); - continue; - } } - return ret; } + /* EOF */ } Modified: trunk/fingerprint-reader/src/wizards.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/fingerprint-reader/src/wizards.ycp?rev=39749&r1=39748&r2=39749&view=diff ============================================================================== --- trunk/fingerprint-reader/src/wizards.ycp (original) +++ trunk/fingerprint-reader/src/wizards.ycp Fri Jul 27 16:13:09 2007 @@ -34,80 +34,24 @@ import "Sequencer"; import "Wizard"; -include "fingerprint-reader/complex.ycp"; include "fingerprint-reader/dialogs.ycp"; /** - * Add a configuration of fingerprint-reader - * @return sequence result - */ -any AddSequence() { - - /* FIXME: adapt to your needs */ - map aliases = $[ - "config1" : ``(Configure1Dialog()), - "config2" : ``(Configure2Dialog()), - ]; - - /* FIXME: adapt to your needs */ - map sequence = $[ - "ws_start" : "config1", - "config1" : $[ - `abort : `abort, - `next : "config2" - ], - "config2" : $[ - `abort : `abort, - `next : `next - ] - ]; - - return Sequencer::Run(aliases, sequence); -} - -/** * Main workflow of the fingerprint-reader configuration * @return sequence result */ any MainSequence() { - /* FIXME: adapt to your needs */ map aliases = $[ - "summary" : ``( SummaryDialog() ), - "overview" : ``( OverviewDialog() ), - "configure" : [ ``( AddSequence() ), true ], - "add" : [ ``( AddSequence() ), true ], - "edit" : [ ``( AddSequence() ), true ] + "summary" : ``( FingerprintReaderDialog () ), ]; - /* FIXME: adapt to your needs */ map sequence = $[ "ws_start" : "summary", "summary" : $[ `abort : `abort, `next : `next, - `overview : "overview", - `configure : "configure", - `other : "configure", - ], - "overview" : $[ - `abort : `abort, - `next : `next, - `add : "add", - `edit : "edit", ], - "configure" : $[ - `abort : `abort, - `next : "summary", - ], - "add" : $[ - `abort : `abort, - `next : "overview", - ], - "edit" : $[ - `abort : `abort, - `next : "overview", - ] ]; any ret = Sequencer::Run(aliases, sequence); @@ -159,7 +103,7 @@ any FingerprintReaderAutoSequence() { /* Initialization dialog caption */ - string caption = _("FingerprintReader Configuration"); + string caption = _("Fingerprint Reader Configuration"); /* Initialization dialog contents */ term contents = `Label(_("Initializing...")); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org