[yast-commit] r39846 - in /trunk/squid/src: Squid.ycp SquidACL.ycp SquidACL_local_functions.ycp complex.ycp dialogs.ycp
Author: dfiser Date: Tue Jul 31 17:02:50 2007 New Revision: 39846 URL: http://svn.opensuse.org/viewcvs/yast?rev=39846&view=rev Log: Written a lot of ACLs. And some little improvements. Modified: trunk/squid/src/Squid.ycp trunk/squid/src/SquidACL.ycp trunk/squid/src/SquidACL_local_functions.ycp trunk/squid/src/complex.ycp trunk/squid/src/dialogs.ycp Modified: trunk/squid/src/Squid.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/Squid.ycp?rev=39846&r1=39845&r2=39846&view=diff ============================================================================== --- trunk/squid/src/Squid.ycp (original) +++ trunk/squid/src/Squid.ycp Tue Jul 31 17:02:50 2007 @@ -184,6 +184,10 @@ { acls[id_item] = value; } +global void DelACL(integer id_item) +{ + acls = remove(acls, id_item); +} /******* ACL END *******/ /******* HTTP_ACCESS ******/ @@ -419,7 +423,7 @@ return ok; } -/** +/** TODO: Regular expressions! * Read setting of parameter acl. * acl aclname acltype string1 string2 ... * @@ -431,6 +435,14 @@ list tmp = []; map <string, any> tmp_acl = $[]; + //list of types which contains regular expression + list<string> regexps = [ + "srcdom_regex", + "dstdom_regex", + "url_regex", + "urlpath_regex", + "browser" + ]; acls = []; foreach (string value, (list<string>)SCR::Read( add(squid_path, "acl")), @@ -448,6 +460,15 @@ tmp_acl["type"] = tmp[1]:""; tmp_acl["options"] = remove(remove(tmp,0),0); + // concat list of regular expressions into one option + if (contains(regexps, tmp_acl["type"]:"")){ + if ((tmp_acl["options"]:[])[0]:"" == "-i"){ + tmp_acl["options"] = ["-i", mergestring((list<string>)remove(tmp_acl["options"]:[], 0), " ")]; + }else{ + tmp_acl["options"] = [mergestring(tmp_acl["options"]:[], " ")]; + } + } + acls = add(acls, tmp_acl); }); return ok; Modified: trunk/squid/src/SquidACL.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/SquidACL.ycp?rev=39846&r1=39845&r2=39846&view=diff ============================================================================== --- trunk/squid/src/SquidACL.ycp (original) +++ trunk/squid/src/SquidACL.ycp Tue Jul 31 17:02:50 2007 @@ -40,29 +40,29 @@ * "type" : $[ "name" : "Name shown in dialogs", * "widget" : `WidgetDescribingThisType, * "widget_init" : FunctionWithInitsOfWidget, - * "verification_func" : FunctionCalledToVerificateContentsOfWidget, - * "store_func" : FunctionCalledToStoreDataFromWidget //returns list of options + * "verification" : FunctionCalledToVerificateContentsOfWidget, + * "options" : FunctionThatReturnsListOfOptions * ] * ] * * widget_init prototype: void FuncName(integer id_item) - * verification_func prototype: boolean FuncName() - * store_func prototype: list<string> FuncName() + * verification prototype: boolean FuncName() + * options prototype: list<string> FuncName() */ map<string,map> acl_map = $[ "src" : $[ "name" : "src", "widget" : `Frame( _("src"), `VBox( - `TextEntry(`id("acl_addr1"), _("IP Address 1"), ""), + //`TextEntry(`id("acl_addr1"), _("IP Address 1"), ""), //`Label(" - "), - `TextEntry(`id("acl_addr2"), _("IP Address 2"), ""), + `TextEntry(`id("acl_addr"), _("IP Address or Range of IP Addresses"), ""), //`Label("/"), `TextEntry(`id("acl_mask"), _("Network Mask"), "") ) ), "widget_init" : srcWidgetInit, - "verification_func" : srcVerif, - "store_func" : srcStore ], + "verification" : srcVerif, + "options" : srcOptions ], "dst" : $[ "name" : "dst", "widget" : `Frame( _("dst"), @@ -72,26 +72,137 @@ ) ), "widget_init" : dstWidgetInit, - "verification_func" : dstVerif, - "store_func" : dstStore ], + "verification" : dstVerif, + "options" : dstOptions ], "myip" : $[ "name" : "myip", "widget" : `Frame( _("myip"), `VBox( `TextEntry(`id("acl_addr"), _("Local IP Address"), ""), `TextEntry(`id("acl_mask"), _("Network Mask"), "") - ) + ) + ), + "widget_init" : dstWidgetInit, + "verification" : dstVerif, + "options" : dstOptions ], + + "srcdomain" : $[ "name" : "srcdomain", + "widget" : `Frame( _("srcdomain"), + `VBox( + `TextEntry(`id("acl_domain"), _("Clients Domain Name"), "") + ) + ), + "widget_init" : srcdomainWidgetInit, + "verification" : srcdomainVerif, + "options" : srcdomainOptions ], + + "dstdomain" : $[ "name" : "dstdomain", + "widget" : `Frame( _("dstdomain"), + `VBox( + `TextEntry(`id("acl_domain"), _("Destination Domain"), "") + ) + ), + "widget_init" : srcdomainWidgetInit, + "verification" : srcdomainVerif, + "options" : srcdomainOptions ], + + "srcdom_regex" : regexp("srcdom_regex", "srcdom_regex"), + "dstdom_regex" : regexp("dstdom_regex", "dstdom_regex"), + + "time" : $[ "name" : "time", + "widget" : `Frame( _("time"), + `VBox( + `HWeight(1, `MinHeight(8, `MultiSelectionBox(`id("acl_days"), _("Days"), + [`item(`id("M"), "Monday"), + `item(`id("T"), "Tuesday"), + `item(`id("W"), "Wednesday"), + `item(`id("H"), "Thursday"), + `item(`id("F"), "Friday"), + `item(`id("A"), "Saturday"), + `item(`id("S"), "Sunday")]))), + `HWeight(1, `HBox( + `TextEntry(`id("acl_from"), `opt(`shrinkable), _("From (H:M)"), ""), + `TextEntry(`id("acl_to"), `opt(`shrinkable), _("To (H:M)"), "") + )) + ) + ), + "widget_init" : timeWidgetInit, + "verification" : timeVerif, + "options" : timeOptions ], + + "url_regex" : regexp("url_regex", "url_regex"), + "urlpath_regex" : regexp("urlpath_regex", "urlpath_regex"), + + "port" : $[ "name" : "port", + "widget" : `Frame( _("port"), + `TextEntry(`id("acl_port"), _("Port Number or Range of Ports"), "") ), - "widget_init" : myipWidgetInit, - "verification_func" : myipVerif, - "store_func" : myipStore ] + "widget_init" : portWidgetInit, + "verification" : portVerif, + "options" : portOptions ], + + "myport" : $[ "name" : "myport", + "widget" : `Frame( _("myport"), + `TextEntry(`id("acl_port"), _("Port Number"), "") + ), + "widget_init" : myportWidgetInit, + "verification" : myportVerif, + "options" : portOptions ], + + "proto" : $[ "name" : "proto", + "widget" : `Frame ( _("proto"), + `TextEntry(`id("acl_proto"), _("Protocol"), "") + ), + "widget_init" : protoWidgetInit, + "verification" : protoVerif, + "options" : protoOptions ], + + "method" : $[ "name" : "method", + "widget" : `Frame( _("method"), + `ComboBox(`id("acl_method"), _("HTTP Method"), + [`item(`id("GET"), "GET"), + `item(`id("HEAD"), "HEAD"), + `item(`id("POST"), "POST"), + `item(`id("PUT"), "PUT"), + `item(`id("DELETE"), "DELETE"), + `item(`id("TRACE"), "TRACE"), + `item(`id("CONNECT"), "CONNECT")]) + ), + "widget_init" : methodWidgetInit, + "verification" : methodVerif, + "options" : methodOptions ], + + "browser" : regexp("browser", "browser"), + + "maxconn" : $[ "name" : "maxconn", + "widget" : `Frame("maxconn", + `IntField(`id("acl_connections"), _("Maximum Number of HTTP Connections"), 0, 999999, 0) + ), + "widget_init" : maxconnWidgetInit, + "verification" : maxconnVerif, + "options" : maxconnOptions ] ]; /** * Specify order of acls. * Values must corespond with keys in acl_map. */ -list<string> acl_order = ["src", "dst", "myip"]; +list<string> acl_order = ["src", + "dst", + "myip", + "srcdomain", + "dstdomain", + "srcdom_regex", + "dstdom_regex", + "time", + "url_regex", + "urlpath_regex", + "port", + "myport", + "proto", + "method", + "browser", + "maxconn"]; @@ -141,14 +252,18 @@ */ global boolean Verify(string id_acl_type) { - boolean() func = (boolean())(acl_map[id_acl_type]:$[])["verification_func"]:nil; + boolean() func = (boolean())(acl_map[id_acl_type]:$[])["verification"]:nil; return (boolean)func(); } -global list<string> Store(string id_acl_type) +/** + * Returns values from widget as list of options in correct form to store + * them into Squid module. + */ +global list<string> GetOptions(string id_acl_type) { - list<string>() func = (list<string>())(acl_map[id_acl_type]:$[])["store_func"]:nil; + list<string>() func = (list<string>())(acl_map[id_acl_type]:$[])["options"]:nil; return func(); } } Modified: trunk/squid/src/SquidACL_local_functions.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/SquidACL_local_functions.ycp?rev=39846&r1=39845&r2=39846&view=diff ============================================================================== --- trunk/squid/src/SquidACL_local_functions.ycp (original) +++ trunk/squid/src/SquidACL_local_functions.ycp Tue Jul 31 17:02:50 2007 @@ -33,14 +33,46 @@ import "Squid"; +list<string> splitToChars(string str) +{ + integer len = size(str); + integer i = 0; + list<string> ret = []; + while (i<len){ + ret = add(ret, substring(str,i,1)); + i = i + 1; + } + + return (ret); +} -boolean isIPAddress(string str) +boolean isIPAddr(string str) { - return regexpmatch(str, "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); + return regexpmatch(str, "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$"); } boolean isMask(string str) { - return regexpmatch(str, "[0-9]+") || isIPAddress(str); + return regexpmatch(str, "^[0-9]+$") || isIPAddr(str); +} +boolean isHHMMFormat(string str) +{ + if (!regexpmatch(str, "^[0-9]{1,2}:[0-9]{1,2}$")) return false; + list<string> hm = splitstring(str, ":"); + integer tmp = 0; + + tmp = tointeger(hm[0]:""); + if (tmp < 0 || tmp > 23) return false; + tmp = tointeger(hm[1]:""); + if (tmp < 0 || tmp > 59) return false; + + return true; +} +boolean isCorrectFromTo(string from, string to) +{ + integer fr = tointeger(regexpsub(mergestring(splitstring(from, ":"), ""), "([1-9][0-9]*$)", "\\1")); + integer t = tointeger(regexpsub(mergestring(splitstring(to, ":"),""), "([1-9][0-9]*$)", "\\1")); + + return fr<t; } @@ -53,45 +85,40 @@ { UI::ChangeWidget(`id(id), `ValidChars, "1234567890."); } +void widgetInitDomainName(any id) +{ + UI::ChangeWidget(`id(id), `ValidChars, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ."); +} +void widgetInitHHMM(any id) +{ + UI::ChangeWidget(`id(id), `ValidChars, "1234567890:"); + UI::ChangeWidget(`id(id), `InputMaxLength, 5); +} /****************** SRC *************************/ -void srcWidgetInit(integer id_item)//TODO: +void srcWidgetInit(integer id_item) { - widgetInitIPAddr("acl_addr1"); - widgetInitIPAddr("acl_addr2"); + UI::ChangeWidget(`id("acl_addr"), `ValidChars, "1234567890.-"); widgetInitMask("acl_mask"); if (id_item != nil){ map<string,any> acl = Squid::GetACL(id_item); - list<string> tmp = []; list<string> data = splitstring((acl["options"]:[])[0]:"", "/"); - data[2] = data[1]:""; - tmp = splitstring(data[0]:"", "-"); - if (size(tmp) == 1){ - data[0] = ""; - data[1] = tmp[0]:""; - }else{ - data[0] = tmp[0]:""; - data[1] = tmp[1]:""; - } - y2debug("%1", data); - UI::ChangeWidget(`id("acl_addr1"), `Value, data[0]:""); - UI::ChangeWidget(`id("acl_addr2"), `Value, data[1]:""); - UI::ChangeWidget(`id("acl_mask"), `Value, data[2]:""); + UI::ChangeWidget(`id("acl_addr"), `Value, data[0]:""); + UI::ChangeWidget(`id("acl_mask"), `Value, data[1]:""); } } boolean srcVerif(){ boolean ok = true; - string addr1 = (string)UI::QueryWidget(`id("acl_addr1"), `Value); - string addr2 = (string)UI::QueryWidget(`id("acl_addr2"), `Value); + string addr = (string)UI::QueryWidget(`id("acl_addr"), `Value); string mask = (string)UI::QueryWidget(`id("acl_mask"), `Value); + list<string> tmp = splitstring(addr, "-"); - if ((size(addr1) == 0 && size(addr2) == 0) || - (size(addr1) > 0 && !isIPAddress(addr1)) || - (size(addr2) > 0 && !isIPAddress(addr2)) || + if (size(addr) == 0 || + (!isIPAddr(addr) && !isIPAddr(tmp[0]:"") && !isIPAddr(tmp[1]:"")) || (size(mask) > 0 && !isMask(mask))){ ok = false; Report::Error( _("Invalid values.")); @@ -99,18 +126,13 @@ return ok; } -list<string> srcStore(){ +list<string> srcOptions(){ list<string> data = []; - string addr1 = (string)UI::QueryWidget(`id("acl_addr1"), `Value); - string addr2 = (string)UI::QueryWidget(`id("acl_addr2"), `Value); + string addr = (string)UI::QueryWidget(`id("acl_addr"), `Value); string mask = (string)UI::QueryWidget(`id("acl_mask"), `Value); - if (size(addr1) > 0 && size(addr2) > 0){ - data[0] = addr1 + "-" + addr2; - }else{ - data[0] = addr1 + addr2; - } - if (size(mask) > 0 && size(addr1)+size(addr2) > 0) + data[0]=addr; + if (size(mask) > 0 && size(addr) > 0) data[0] = data[0]:"" + "/" + mask; return data; } @@ -138,14 +160,14 @@ string addr = (string)UI::QueryWidget(`id("acl_addr"), `Value); string mask = (string)UI::QueryWidget(`id("acl_mask"), `Value); - if (!isIPAddress(addr) || (size(mask) > 0 && !isMask(mask))){ + if (!isIPAddr(addr) || (size(mask) > 0 && !isMask(mask))){ ok = false; Report::Error( _("Invalid values.")); } return ok; } -list<string> dstStore() +list<string> dstOptions() { list<string> data = []; string addr = (string)UI::QueryWidget(`id("acl_addr"), `Value); @@ -159,20 +181,283 @@ /****************** DST END *********************/ -/****************** MYIP ************************/ -void myipWidgetInit(integer id_item) +/****************** MYIP ************************ + * Uses same functions as DST +/****************** MYIP END ********************/ + + +/**************** SRCDOMAIN *********************/ +void srcdomainWidgetInit(integer id_item) { - widgetInitIPAddr("acl_addr"); - widgetInitMask("acl_mask"); + widgetInitDomainName("acl_domain"); + + if (id_item != nil){ + map<string, any> acl = Squid::GetACL(id_item); + UI::ChangeWidget(`id("acl_domain"), `Value, (acl["options"]:[])[0]:""); + } } -boolean myipVerif() +boolean srcdomainVerif() +{ + boolean ok = true; + + if (size((string)UI::QueryWidget(`id("acl_domain"), `Value)) == 0){ + ok = false; + Report::Error( _("Domain Name must not be empty.")); + } + return ok; +} +list<string> srcdomainOptions() +{ + return [(string)UI::QueryWidget(`id("acl_domain"), `Value)]; +} +/**************** SRCDOMAIN END *****************/ + +/**************** DSTDOMAIN ********************* + * Uses same functions as SRCDOMAIN. +/**************** DSTDOMAIN END *****************/ + + +/**************** REGEXP ************************/ +/** + * Returns univerzal widget for setting a regular expression. + */ +term regexpWidget(string frame_title) +{ + return `Frame( frame_title, + `VBox( + `TextEntry(`id("acl_regexp"), _("Regular Expression"), ""), + `CheckBox(`id("acl_regexp_case_insensitive"), _("Case Insensitive"), false) + ) + ); +} + +/** + * Univerzal widget_init for regular expression. + */ +void regexpWidgetInit(integer id_item) +{ + if (id_item != nil){ + map <string,any> acl = Squid::GetACL(id_item); + + if ((acl["options"]:[])[0]:"" == "-i"){ + UI::ChangeWidget(`id("acl_regexp_case_insensitive"), `Value, true); + acl["options"] = remove(acl["options"]:[],0); + } + UI::ChangeWidget(`id("acl_regexp"), `Value, (acl["options"]:[])[0]:""); + } +} +/** + * Univerzal verification function for regular expression. + */ +boolean regexpVerif() +{ + boolean ok = true; + string regexp = (string)UI::QueryWidget(`id("acl_regexp"), `Value); + + if (size(regexp) == 0){ + ok = false; + Report::Error( _("Regular Expression must not be empty.")); + } + return ok; +} +/** + * Univerzal options function for regular expression. + */ +list<string> regexpOptions() +{ + list<string> ret = []; + if ((boolean)UI::QueryWidget(`id("acl_regexp_case_insensitive"), `Value)) + ret[0] = "-i"; + ret = add(ret, (string)UI::QueryWidget(`id("acl_regexp"), `Value)); + return ret; +} + +/** + * Returns map describing acl which has type of regular expression. + */ +map<string,any> regexp(string name, string frame_title) +{ + return $[ "name" : name, + "widget" : regexpWidget(frame_title), + "widget_init" : regexpWidgetInit, + "verification" : regexpVerif, + "options" : regexpOptions ]; +} +/**************** REGEXP END ********************/ + + + +/**************** TIME **************************/ +void timeWidgetInit(integer id_item) +{ + widgetInitHHMM("acl_from"); + widgetInitHHMM("acl_to"); + + if (id_item != nil){ + map<string,any> acl = Squid::GetACL(id_item); + list<string> days = splitToChars((acl["options"]:[])[0]:""); + list<string> times = splitstring((acl["options"]:[])[1]:"","-"); + + UI::ChangeWidget(`id("acl_days"), `SelectedItems, days); + UI::ChangeWidget(`id("acl_from"), `Value, times[0]:""); + UI::ChangeWidget(`id("acl_to"), `Value, times[1]:""); + } +} +boolean timeVerif() +{ + boolean ok = true; + string from = (string)UI::QueryWidget(`id("acl_from"), `Value); + string to = (string)UI::QueryWidget(`id("acl_to"), `Value); + integer selected_items = size((list)UI::QueryWidget(`id("acl_days"), `SelectedItems)); + + if (selected_items == 0){ + ok = false; + Report::Error( _("You must select at least on day.")); + }else if (!isHHMMFormat(from) || !isHHMMFormat(to)){ + ok = false; + Report::Error( _("Time isn't filled in corrent format.")); + }else if (!isCorrectFromTo(from, to)){// from must be less then to + ok = false; + Report::Error( _("From must be less then To."));//TODO: better error message + } + return ok; +} +list<string> timeOptions() +{ + string days = mergestring((list<string>)UI::QueryWidget(`id("acl_days"), `SelectedItems),""); + string times = mergestring([(string)UI::QueryWidget(`id("acl_from"), `Value), + (string)UI::QueryWidget(`id("acl_to"), `Value)], "-"); + return [days, times]; +} +/**************** TIME END **********************/ + + +/**************** PORT **************************/ +void portWidgetInit(integer id_item) +{ + UI::ChangeWidget(`id("acl_port"), `ValidChars, "1234567890-"); + + if (id_item != nil){ + map<string,any> acl = Squid::GetACL(id_item); + + UI::ChangeWidget(`id("acl_port"), `Value, (acl["options"]:[])[0]:""); + } +} +boolean portVerif() +{ + boolean ok = true; + string port = (string)UI::QueryWidget(`id("acl_port"), `Value); + + if (!regexpmatch(port, "^[0-9]+(-[0-9]+){0,1}$")){ + ok = false; + }else{ + list<string> ports = splitstring(port, "-"); + if (size(ports) == 2 && (tointeger(ports[0]:"") > tointeger(ports[1]:""))){ + ok = false; + } + } + if (!ok){ + Report::Error( _("Invalid value.")); + } + return ok; +} +list<string> portOptions() +{ + return [(string)UI::QueryWidget(`id("acl_port"), `Value)]; +} +/**************** PORT END **********************/ + + +/************** MYPORT **************************/ +void myportWidgetInit(integer id_item) +{ + UI::ChangeWidget(`id("acl_port"), `ValidChars, "1234567890"); + + if (id_item != nil){ + map<string,any> acl = Squid::GetACL(id_item); + + UI::ChangeWidget(`id("acl_port"), `Value, (acl["options"]:[])[0]:""); + } +} +boolean myportVerif() +{ + boolean ok = true; + string port = (string)UI::QueryWidget(`id("acl_port"), `Value); + + if (!regexpmatch(port, "^[0-9]+$")){ + ok = false; + Report::Error( _("Invalid value.")); + } + return ok; +} +/************** MYPORT END **********************/ + + +/*************** PROTO **************************/ +void protoWidgetInit(integer id_item) +{ + UI::ChangeWidget(`id("acl_proto"), `ValidChars, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"); + + if (id_item != nil){ + map<string,any> acl = Squid::GetACL(id_item); + + UI::ChangeWidget(`id("acl_proto"), `Value, (acl["options"]:[])[0]:""); + } +} +boolean protoVerif() +{ + boolean ok = true; + string protocol = (string)UI::QueryWidget(`id("acl_proto"), `Value); + + if (size(protocol) == 0){ + Report::Error( _("Protocol must not be empty.")); + } + return ok; +} +list<string> protoOptions() +{ + return [(string)UI::QueryWidget(`id("acl_proto"), `Value)]; +} +/*************** PROTO END **********************/ + + +/*************** METHOD *************************/ +void methodWidgetInit(integer id_item) +{ + if (id_item != nil){ + map<string,any> acl = Squid::GetACL(id_item); + + UI::ChangeWidget(`id("acl_method"), `Value, (acl["options"]:[])[0]:""); + } +} +boolean methodVerif() { return true; } -list<string> myipStore() +list<string> methodOptions() { - return []; + return [(string)UI::QueryWidget(`id("acl_method"), `Value)]; } -/****************** MYIP END ********************/ +/*************** METHOD END *********************/ + + +/*************** MAXCONN ************************/ +void maxconnWidgetInit(integer id_item) +{ + if (id_item != nil){ + map<string,any> acl = Squid::GetACL(id_item); + + UI::ChangeWidget(`id("acl_connections"), `Value, tointeger((acl["options"]:[])[0]:"")); + } +} +boolean maxconnVerif() +{ + return true; +} +list<string> maxconnOptions() +{ + return [tostring(UI::QueryWidget(`id("acl_connections"), `Value))]; +} +/*************** MAXCONN END ********************/ } /* vim: set sw=4 ts=4 et ft=ycp : */ Modified: trunk/squid/src/complex.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/complex.ycp?rev=39846&r1=39845&r2=39846&view=diff ============================================================================== --- trunk/squid/src/complex.ycp (original) +++ trunk/squid/src/complex.ycp Tue Jul 31 17:02:50 2007 @@ -329,9 +329,13 @@ return ok; } -void DelFromHttpPortsTable(integer id_item) +integer DelFromHttpPortsTable(integer id_item) { Squid::DelHttpPort(id_item); + if (id_item >= size(Squid::GetHttpPorts())){ + id_item = id_item - 1; + } + return id_item; } boolean StoreDataFromAddEditRefreshPatternDialog(integer id_item) @@ -360,9 +364,13 @@ return ok; } -void DelFromRefreshPatternsTable(integer id_item) +integer DelFromRefreshPatternsTable(integer id_item) { Squid::DelRefreshPattern(id_item); + if (id_item >= size(Squid::GetRefreshPatterns())){ + id_item = id_item - 1; + } + return id_item; } /** @@ -461,9 +469,13 @@ return ok; } -void DelFromHttpAccessTable(integer id_item) +integer DelFromHttpAccessTable(integer id_item) { Squid::DelHttpAccess(id_item); + if (id_item >= size(Squid::GetHttpAccesses())){ + id_item = id_item - 1; + } + return (id_item); } integer MoveUpHttpAccess(integer id_item) { @@ -499,7 +511,7 @@ if (verification && size(name) > 0){ data["name"] = name; data["type"] = type; - data["options"] = SquidACL::Store(type); + data["options"] = SquidACL::GetOptions(type); y2debug("complex::StoreDataFromAddEditACLDialog() - data: %1", data); @@ -517,6 +529,14 @@ return ok; } +integer DelFromACLGroupsTable(integer id_item) +{ + Squid::DelACL(id_item); + if (id_item >= size(Squid::GetACLs())){ + id_item = id_item - 1; + } + return id_item; +} /********************* STORING + DELETING END ********************/ } Modified: trunk/squid/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/dialogs.ycp?rev=39846&r1=39845&r2=39846&view=diff ============================================================================== --- trunk/squid/src/dialogs.ycp (original) +++ trunk/squid/src/dialogs.ycp Tue Jul 31 17:02:50 2007 @@ -153,8 +153,9 @@ UI::ChangeWidget(`id("http_port"), `CurrentItem, id_item); } }else if (ret == `del){ - DelFromHttpPortsTable((integer)UI::QueryWidget(`id("http_port"), `CurrentItem)); + id_item = DelFromHttpPortsTable((integer)UI::QueryWidget(`id("http_port"), `CurrentItem)); InitHttpPortsTable(); + UI::ChangeWidget(`id("http_port"), `CurrentItem, id_item); } } @@ -266,8 +267,9 @@ UI::ChangeWidget(`id("refresh_patterns"), `CurrentItem, id_item); } }else if (ret == `del){ - DelFromRefreshPatternsTable((integer)UI::QueryWidget(`id("refresh_patterns"), `CurrentItem)); + id_item = DelFromRefreshPatternsTable((integer)UI::QueryWidget(`id("refresh_patterns"), `CurrentItem)); InitRefreshPatternsTable(); + UI::ChangeWidget(`id("refresh_patterns"), `CurrentItem, id_item); }else if (ret == `up){ id_item = MoveUpRefreshPattern((integer)UI::QueryWidget(`id("refresh_patterns"), `CurrentItem)); if (id_item != nil){ @@ -421,7 +423,7 @@ items = add(items, `item(`id(i), (not == true ? "not" : ""), item)); UI::ChangeWidget(`id("acls"), `Items, items); } -void delItemFromAddEditHttpAccessDialog(integer id_item) +integer delItemFromAddEditHttpAccessDialog(integer id_item) { list items = []; @@ -434,6 +436,10 @@ } }); UI::ChangeWidget(`id("acls"), `Items, items); + if (id_item >= size(items)){ + id_item = id_item - 1; + } + return id_item; } boolean AddEditHttpAccessDialog(integer id_item) { @@ -442,6 +448,7 @@ string acl = ""; boolean not = false; any tmp = nil; + integer id_acl = 0; term contents = `VBox( `ComboBox(`id("allow_deny"), _("Allow/Deny"), @@ -493,8 +500,9 @@ InitAddEditHttpAccessDialog(nil); } }else if (ui == `del){ - delItemFromAddEditHttpAccessDialog((integer)UI::QueryWidget(`id("acls"), `CurrentItem)); + id_acl = delItemFromAddEditHttpAccessDialog((integer)UI::QueryWidget(`id("acls"), `CurrentItem)); InitAddEditHttpAccessDialog(nil); + UI::ChangeWidget(`id("acls"), `CurrentItem, id_acl); } } @@ -509,6 +517,7 @@ { boolean ret = false; any ui = nil; + string orig_type = ""; string type = ""; term contents = `VBox( @@ -526,9 +535,9 @@ InitAddEditACLDialog(id_item); - type = (string)UI::QueryWidget(`id("type"), `Value); - SquidACL::Replace(`replace_point, type); - SquidACL::InitWidget(type, id_item); + orig_type = (string)UI::QueryWidget(`id("type"), `Value); + SquidACL::Replace(`replace_point, orig_type); + SquidACL::InitWidget(orig_type, id_item); while (true){ ui = UI::UserInput(); @@ -544,7 +553,11 @@ }else if (ui == "type"){ type = (string)UI::QueryWidget(`id("type"), `Value); SquidACL::Replace(`replace_point, type); - SquidACL::InitWidget(type, id_item); + if (type == orig_type){ + SquidACL::InitWidget(type, id_item); + }else{ + SquidACL::InitWidget(type, nil); + } } } @@ -611,6 +624,10 @@ InitACLGroupsTable(); UI::ChangeWidget(`id("acl"), `CurrentItem, id_item); } + }else if (ret == `del_acl){ + id_item = DelFromACLGroupsTable((integer)UI::QueryWidget(`id("acl"), `CurrentItem)); + InitACLGroupsTable(); + UI::ChangeWidget(`id("acl"), `CurrentItem, id_item); }else if (ret == `add_http_access){ if (AddEditHttpAccessDialog(nil)){ @@ -623,8 +640,9 @@ UI::ChangeWidget(`id("http_access"), `CurrentItem, id_item); } }else if (ret == `del_http_access){ - DelFromHttpAccessTable((integer)UI::QueryWidget(`id("http_access"), `CurrentItem)); + id_item = DelFromHttpAccessTable((integer)UI::QueryWidget(`id("http_access"), `CurrentItem)); InitHttpAccessTable(); + UI::ChangeWidget(`id("http_access"), `CurrentItem, id_item); }else if (ret == `up_http_access){ id_item = MoveUpHttpAccess((integer)UI::QueryWidget(`id("http_access"), `CurrentItem)); if (id_item != nil){ -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
dfiser@svn.opensuse.org