[yast-commit] r67444 - in /trunk/s390/src: dasd/dialogs.ycp modules/DASDController.ycp
Author: aschnell Date: Wed Feb 15 14:52:22 2012 New Revision: 67444 URL: http://svn.opensuse.org/viewcvs/yast?rev=67444&view=rev Log: - added basic input checks Modified: trunk/s390/src/dasd/dialogs.ycp trunk/s390/src/modules/DASDController.ycp Modified: trunk/s390/src/dasd/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/dasd/dialogs.ycp?rev=67444&r1=67443&r2=67444&view=diff ============================================================================== --- trunk/s390/src/dasd/dialogs.ycp (original) +++ trunk/s390/src/dasd/dialogs.ycp Wed Feb 15 14:52:22 2012 @@ -214,9 +214,6 @@ */ void ReloadDASDDialog() { - DASDController::filter_min = (string) UI::QueryWidget(`min_chan, `Value); - DASDController::filter_max = (string) UI::QueryWidget(`max_chan, `Value); - list<term> items = GetDASDDiskItems(); list<integer> selected = (list<integer>) UI::QueryWidget(`id(`table), `SelectedItems); @@ -242,6 +239,20 @@ if (ret == `filter) { + string filter_min = (string) UI::QueryWidget(`min_chan, `Value); + string filter_max = (string) UI::QueryWidget(`max_chan, `Value); + + if (!DASDController::ValidChannel(filter_min) || !DASDController::ValidChannel(filter_max)) + { + // error popup + Popup::Error(_("Invalid filter channels.")); + ret = nil; + continue; + } + + DASDController::filter_min = filter_min; + DASDController::filter_max = filter_max; + ReloadDASDDialog (); ret = nil; continue; @@ -499,10 +510,24 @@ { ret = nil; } - } + } else if (ret == `next) { - // TODO check for duplicate channel + string channel = (string) UI::QueryWidget(`id(`channel), `Value); + + if (!DASDController::ValidChannel(channel)) + { + // error popup + Popup::Error(_("Not a valid channel.")); + ret = nil; + } + + if (DASDController::GetDeviceIndex(channel) != nil) + { + // error popup + Popup::Error(_("Channel already exists.")); + ret = nil; + } } } @@ -511,7 +536,8 @@ string channel = (string) UI::QueryWidget(`id(`channel), `Value); boolean format = (boolean) UI::QueryWidget(`id(`format), `Value); boolean diag = (boolean) UI::QueryWidget(`id(`diag), `Value); - map<string,any> m = $[ + + map<string, any> d = $[ "channel" : channel, "format" : format, "diag" : diag, @@ -520,7 +546,7 @@ integer index = 0; while (haskey (DASDController::devices, index)) index = index + 1; - DASDController::devices[index] = m; + DASDController::devices[index] = d; } return ret; Modified: trunk/s390/src/modules/DASDController.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/modules/DASDController.ycp?rev=67444&r1=67443&r2=67444&view=diff ============================================================================== --- trunk/s390/src/modules/DASDController.ycp (original) +++ trunk/s390/src/modules/DASDController.ycp Wed Feb 15 14:52:22 2012 @@ -109,6 +109,13 @@ } + global boolean ValidChannel(string channel) + { + string regexp = "^([0-9a-fA-F]{1}).([0-9a-fA-F]{1}).([0-9a-fA-F]{4})$"; + return regexpmatch(channel, regexp); + } + + /** * Read all controller settings * @return true on success @@ -261,6 +268,18 @@ return ret; } + + global integer + GetDeviceIndex(string channel) + { + integer ret = nil; + foreach(integer index , map<string, any> d, DASDController::devices, { + if (d["channel"]:"0.0.0000" == channel) + ret = index; + }); + return ret; + } + /** * Create a textual summary and a list of unconfigured cards -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
aschnell@svn2.opensuse.org