Author: jsuchome Date: Fri Jul 13 16:17:44 2007 New Revision: 39404 URL: http://svn.opensuse.org/viewcvs/yast?rev=39404&view=rev Log: small issues for testing... Modified: trunk/fingerprint-reader/src/UsersPluginFingerprintReader.pm trunk/fingerprint-reader/src/users_plugin_fingerprint_reader.ycp Modified: trunk/fingerprint-reader/src/UsersPluginFingerprintReader.pm URL: http://svn.opensuse.org/viewcvs/yast/trunk/fingerprint-reader/src/UsersPluginFingerprintReader.pm?rev=39404&r1=39403&r2=39404&view=diff ============================================================================== --- trunk/fingerprint-reader/src/UsersPluginFingerprintReader.pm (original) +++ trunk/fingerprint-reader/src/UsersPluginFingerprintReader.pm Fri Jul 13 16:17:44 2007 @@ -27,52 +27,36 @@ # error message, returned when some plugin function fails my $error = ""; -##-------------------------------------- - -# All functions have 2 "any" parameters: this will probably mean -# 1st: configuration map (hash) - e.g. saying if we work with user -# 2nd: data map (hash) of user to work with - -# in 'config' map there is a info of this type: -# "what" => "user" / "group" -# "modified" => "added"/"edited"/"deleted" -# "enabled" => 1/ key not present -# "disabled" => 1/ key not present -# "plugins_to_remove" => list of plugins which has to be removed - -# 'data' map contains the atrtributes of the user. It could also contain -# some keys, which Users module uses internaly (like 'groupname' for name of -# user's default group). Just ignore these values - -# -- Warning messages -- -# There is a special way, when you want to give user additional information -# (warning) about some issues appeared during the function. -# -# These keys can be saved by plugin to the result structure of AddBefore, -# Add, EditBefore, Edit, Enable, Disable calls: -# "warning_message" => STRING -# Translated message that should be shown to user (probably as a popup) -# "warning_message_ID" => STRING -# The ID of the message (optional). -# -# This key can be present in user $data hash: -# "confirmed_warnings" => HASH (in the form { message_ID_1 => 1 }) -# (This has sense only if plugin uses optional "warning_message_ID" key) -# Indicates which messages were already shown to this user. -# Plugin function may check for existence of the message_ID_1 in this -# hash before generating "warning_message", to realize if this message -# was alredy shown before (in the same situation). -# See example in AddBefore function. - -##------------------------------------ +my $fingerprint_reader_available = undef; + +##---------------------------------------- +##--------------------- internal functions # helper, check if Fingerprint Reader was already configured +#FIXME do a pam-config query sub fingerprint_reader_configured { - #FIXME do a pam-config query return YaST::YCP::Boolean (1); } +# helper, check if Fingerprint Reader is available +#FIXME check for pam package installed? better do some hw check... +sub is_fingerprint_reader_available { + + if (not defined $fingerprint_reader_available) { + $fingerprint_reader_available = Package->Installed ("pam_thinkfinger"); + } + return $fingerprint_reader_available; +} + +##------------------------------------------ +##--------------------- global API functions + +# All functions have 2 "any" parameters: these mean: +# 1st: configuration map (hash) - e.g. saying if we work with user or group +# 2nd: data map (hash) of user/group to work with +# for details, see UsersPluginLDAPAll.pm + # return names of provided functions BEGIN { $TYPEINFO{Interface} = ["function", ["list", "string"], "any", "any"];} sub Interface { @@ -119,7 +103,7 @@ my $self = shift; # plugin summary (table item) - my $ret = __("Set the fingerprint of an User"); + my $ret = __("Set the user's fingerprint"); return $ret; } @@ -149,7 +133,6 @@ BEGIN { $TYPEINFO{GUIClient} = ["function", "string", "any", "any"];} sub GUIClient { - my $self = shift; return "users_plugin_fingerprint_reader"; } @@ -164,10 +147,11 @@ sub Restriction { my $self = shift; + # do the check here, so the plugin is not shown when there is no hw for it + return {} if not is_fingerprint_reader_available (); return { "local" => 1, "system" => 1, -# "ldap" => 1, #only for local ldap users? # only for users "user" => 1, }; Modified: trunk/fingerprint-reader/src/users_plugin_fingerprint_reader.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/fingerprint-reader/src/users_plugin_fingerprint_reader.ycp?rev=39404&r1=39403&r2=39404&view=diff ============================================================================== --- trunk/fingerprint-reader/src/users_plugin_fingerprint_reader.ycp (original) +++ trunk/fingerprint-reader/src/users_plugin_fingerprint_reader.ycp Fri Jul 13 16:17:44 2007 @@ -56,6 +56,7 @@ `ReplacePoint (`id (`rp), `Label (`id (`label), "Initializing...") ), + `PushButton (`id (`cancel), Label::CancelButton ()), `VSpacing (0.5) ), `HSpacing (1.5) @@ -66,12 +67,11 @@ // dialog caption Wizard::SetContentsButtons(caption, contents, help_text, - Label::CancelButton(), Label::AcceptButton()); + Label::BackButton(), Label::AcceptButton()); Wizard::HideAbortButton (); Wizard::DisableNextButton (); - - + Wizard::DisableBackButton (); string swipe_string (map statemap) { @@ -79,7 +79,15 @@ statemap["swipe_success"]:0, statemap["swipe_failed"]:0); } - SCR::Execute (.thinkfinger.add-user, data["uid"]:""); + boolean exit = false; + any ui = nil; + + if (SCR::Execute (.thinkfinger.add-user, data["uid"]:"") != true) + { + ui = `cancel; + // status message + UI::ReplaceWidget (`id (`rp), `Label ("Initialization of fingerprint reader failed.")); + } /* UI::OpenDialog (`VBox (`HSpacing (20), @@ -89,16 +97,14 @@ `PushButton (`id(`ok), "Cancel") )); */ - boolean exit = false; - while (true) - { - - map statemap = (map) SCR::Read (.thinkfinger.state); - if (statemap != nil && statemap != $[]) + while (ui != `cancel) { + map statemap = (map) SCR::Read (.thinkfinger.state); + if (statemap != nil && statemap != $[]) + { y2warning ("statemap: %1", statemap); - string state = statemap["state"]:""; - switch (state) { + string state = statemap["state"]:""; + switch (state) { case "TF_STATE_ACQUIRE_SUCCESS": { UI::ReplaceWidget (`id (`rp), `Label ("Success")); exit = true; @@ -121,23 +127,35 @@ UI::ReplaceWidget (`id (`rp), `Label (swipe_string (statemap))); break; } + } + } + else if (statemap == nil) + { + break; } + if (exit) break;//must be before check for cancel - } - else if (statemap == nil) - { - break; - } + ui = UI::PollInput (); - any r = UI::PollInput (); - if (r == `cancel || exit) break; - sleep (5); + if (ui == `cancel || ui == `back) + { +y2internal ("ui: %1", ui); + break; + //FIXME solve canceling... + } + + sleep (5); } - if (SCR::Read (.thinkfinger.exit_status) == true) + if (ui != `cancel && SCR::Read (.thinkfinger.exit_status) == true) { // new id was already saved Wizard::DisableBackButton (); Wizard::EnableNextButton (); + UI::ChangeWidget (`id (`cancel), `Enabled, false); + } + else + { + Wizard::EnableBackButton (); } UI::UserInput (); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org