Author: dfiser
Date: Wed Aug 1 13:06:25 2007
New Revision: 39866
URL: http://svn.opensuse.org/viewcvs/yast?rev=39866&view=rev
Log:
Squid: rewrited Add/Modify functions.
SquidACL: added few ACLs, added function SupportedACLs
dialogs.ycp: splitted into dialogs.ycp and popup_dialogs.ycp
complex.ycp: in table ACL Groups will be displayed only ACLs which are supported
Added:
trunk/squid/src/popup_dialogs.ycp
Modified:
trunk/squid/src/Makefile.am
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/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/Makefile.am?rev=39866&r1=39865&r2=39866&view=diff
==============================================================================
--- trunk/squid/src/Makefile.am (original)
+++ trunk/squid/src/Makefile.am Wed Aug 1 13:06:25 2007
@@ -11,6 +11,7 @@
helps.ycp \
wizards.ycp \
dialogs.ycp \
+ popup_dialogs.ycp \
complex.ycp \
SquidACL_local_functions.ycp
Modified: trunk/squid/src/Squid.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/Squid.ycp?rev=39866&r1=39865&r2=39866&view=diff
==============================================================================
--- trunk/squid/src/Squid.ycp (original)
+++ trunk/squid/src/Squid.ycp Wed Aug 1 13:06:25 2007
@@ -62,7 +62,7 @@
/**
* List of http_ports. Format:
* [ $["host" : "hostname",
- * "port" : 3128,
+ * "port" : "3128",
* "transparent" : true],
* ...
* ]
@@ -92,9 +92,9 @@
* List of refresh patterns. Format:
* [ $["regexp" : "^ftp:",
* "case_sensitive" : true,
- * "min" : 12,
- * "max" : 12,
- * "percent" : 12],
+ * "min" : "12",
+ * "max" : "12",
+ * "percent" : "12"],
* ...
* ]
*/
@@ -176,13 +176,17 @@
{
return acls[id_item]:$[];
}
-global void AddACL(map data)
+global void AddACL(string name, string type, list<string> options)
{
- acls = add(acls, data);
+ acls = add(acls, $[ "name" : name,
+ "type" : type,
+ "options" : options]);
}
-global void ModifyACL(integer id_item, map value)
+global void ModifyACL(integer id_item, string name, string type, list<string> options)
{
- acls[id_item] = value;
+ acls[id_item] = $[ "name" : name,
+ "type" : type,
+ "options" : options];
}
global void DelACL(integer id_item)
{
@@ -199,13 +203,15 @@
{
return http_accesses[id_item]:$[];
}
-global void AddHttpAccess(map value)
+global void AddHttpAccess(boolean allow, list<string> acl)
{
- http_accesses = add(http_accesses, value);
+ http_accesses = add(http_accesses, $["allow" : allow,
+ "acl" : acl]);
}
-global void ModifyHttpAccess(integer id_item, map value)
+global void ModifyHttpAccess(integer id_item, boolean allow, list<string> acl)
{
- http_accesses[id_item] = value;
+ http_accesses[id_item] = $["allow" : allow,
+ "acl" : acl];
}
global void DelHttpAccess(integer id_item)
{
@@ -243,13 +249,21 @@
{
return refresh_patterns[id_item]:$[];
}
-global void AddRefreshPattern(map data)
+global void AddRefreshPattern(string regexp, string min, string percent, string max, boolean case_sensitive)
{
- refresh_patterns = add(refresh_patterns, data);
-}
-global void ModifyRefreshPattern(integer id_item, map data)
-{
- refresh_patterns[id_item] = data;
+ refresh_patterns = add(refresh_patterns, $[ "regexp" : regexp,
+ "min" : min,
+ "percent" : percent,
+ "max" : max,
+ "case_sensitive" : case_sensitive]);
+}
+global void ModifyRefreshPattern(integer id_item, string regexp, string min, string percent, string max, boolean case_sensitive)
+{
+ refresh_patterns[id_item] = $[ "regexp" : regexp,
+ "min" : min,
+ "percent" : percent,
+ "max" : max,
+ "case_sensitive" : case_sensitive];
}
global void DelRefreshPattern(integer id_item)
{
@@ -272,13 +286,17 @@
{
return http_ports[id_item]:$[];
}
-global void AddHttpPort(map data)
+global void AddHttpPort(string host, string port, boolean transparent)
{
- http_ports = add(http_ports, data);
+ http_ports = add(http_ports, $["host" : host,
+ "port" : port,
+ "transparent" : transparent]);
}
-global void ModifyHttpPort(integer id_item, map data)
+global void ModifyHttpPort(integer id_item, string host, string port, boolean transparent)
{
- http_ports[id_item] = data;
+ http_ports[id_item] = $["host" : host,
+ "port" : port,
+ "transparent" : transparent];
}
global void DelHttpPort(integer id_item)
{
@@ -423,7 +441,7 @@
return ok;
}
-/** TODO: Regular expressions!
+/**
* Read setting of parameter acl.
* acl aclname acltype string1 string2 ...
*
@@ -460,6 +478,7 @@
tmp_acl["type"] = tmp[1]:"";
tmp_acl["options"] = remove(remove(tmp,0),0);
+ // Special settings:
// concat list of regular expressions into one option
if (contains(regexps, tmp_acl["type"]:"")){
if ((tmp_acl["options"]:[])[0]:"" == "-i"){
@@ -467,6 +486,17 @@
}else{
tmp_acl["options"] = [mergestring(tmp_acl["options"]:[], " ")];
}
+ }else
+ //format: acl aclname header_name [-i] list of regexps
+ if(tmp_acl["type"]:"" == "req_header" || tmp_acl["type"]:"" == "rep_header"){
+ if ((tmp_acl["options"]:[])[1]:"" == "-i"){
+ tmp_acl["options"] = [(tmp_acl["options"]:[])[0]:"",
+ "-i",
+ mergestring((list<string>)remove(remove(tmp_acl["options"]:[], 0), 0), " ")];
+ }else{
+ tmp_acl["options"] = [(tmp_acl["options"]:[])[0]:"",
+ mergestring((list<string>)remove(tmp_acl["options"]:[], 0), " ")];
+ }
}
acls = add(acls, tmp_acl);
Modified: trunk/squid/src/SquidACL.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/SquidACL.ycp?rev=39866&r1=39865&r2=39866&view=diff
==============================================================================
--- trunk/squid/src/SquidACL.ycp (original)
+++ trunk/squid/src/SquidACL.ycp Wed Aug 1 13:06:25 2007
@@ -34,6 +34,30 @@
include "squid/SquidACL_local_functions.ycp";
+list<string> getKeys(map m)
+{
+ list<string> ret = [];
+ foreach(string key, any value, m,
+ {
+ ret = add(ret, key);
+ });
+ return ret;
+}
+
+/***
+ * Unsupported ACLS:
+ * * * * * * * * * * * *
+ * ident, ident_regex,
+ * src_as, dst_as,
+ * proxy_auth, proxy_auth_regex,
+ * snmp_community,
+ * max_user_ip,
+ * external,
+ * urllogin, urlgroup
+ * user_cert, ca_cert
+ * ext_user
+ */
+
/**
* map of acl definition. format:
* $[
@@ -180,33 +204,65 @@
),
"widget_init" : maxconnWidgetInit,
"verification" : maxconnVerif,
- "options" : maxconnOptions ]
+ "options" : maxconnOptions ],
+
+ "referer_regex" : regexp("referer_regex", "referer_regex"),
+
+ "req_header" : $[ "name" : "req_header",
+ "widget" : `Frame( "req_header",
+ `VBox(
+ `TextEntry(`id("acl_header_name"), _("Header Name"), ""),
+ `TextEntry(`id("acl_regexp"), _("Regular Expression(s)"), ""),
+ `CheckBox(`id("acl_regexp_case_insensitive"), _("Case Insensitive"), false)
+ )
+ ),
+ "widget_init" : headerWidgetInit,
+ "verification" : headerVerif,
+ "options" : headerOptions ],
+
+ "rep_header" : $[ "name" : "rep_header",
+ "widget" : `Frame( "rep_header",
+ `VBox(
+ `TextEntry(`id("acl_header_name"), _("Header Name"), ""),
+ `TextEntry(`id("acl_regexp"), _("Regular Expression(s)"), ""),
+ `CheckBox(`id("acl_regexp_case_insensitive"), _("Case Insensitive"), false)
+ )
+ ),
+ "widget_init" : headerWidgetInit,
+ "verification" : headerVerif,
+ "options" : headerOptions ],
+
+ "req_mime_type" : regexp("req_mime_type", "req_mime_type"),
+ "rep_mime_type" : regexp("rep_mime_type", "rep_mime_type"),
+
+ "arp" : $[ "name" : "arp",
+ "widget" : `Frame( "arp",
+ `TextEntry(`id("acl_mac"), _("MAC Address"), "")
+ ),
+ "widget_init" : arpWidgetInit,
+ "verification" : arpVerif,
+ "options" : arpOptions ]
];
/**
- * Specify order of acls.
+ * List of available acls.
+ * Also specify order of acls.
* Values must corespond with keys in acl_map.
*/
-list<string> acl_order = ["src",
- "dst",
- "myip",
- "srcdomain",
- "dstdomain",
- "srcdom_regex",
- "dstdom_regex",
- "time",
- "url_regex",
- "urlpath_regex",
- "port",
- "myport",
- "proto",
- "method",
- "browser",
- "maxconn"];
+list<string> acl = sort(getKeys(acl_map));
/**
+ * Returns list of supported ACLs.
+ * It's necessary to have saved unsupported ACLs but do not handle with them.
+ */
+global list<string> SupportedACLs()
+{
+ return acl;
+}
+
+/**
* Returns list of terms in form:
* [ `item(`id(key), acl_map[key]["name"]:""), `item(... ) ]
* Returned list is preferably to place in UI::ComboBox as list of
@@ -216,7 +272,7 @@
{
list<term> items = [];
- foreach(string value, acl_order,
+ foreach(string value, acl,
{
items = add(items, `item(`id(value), (acl_map[value]:$[])["name"]:""));
});
Modified: trunk/squid/src/SquidACL_local_functions.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/SquidACL_local_functions.ycp?rev=39866&r1=39865&r2=39866&view=diff
==============================================================================
--- trunk/squid/src/SquidACL_local_functions.ycp (original)
+++ trunk/squid/src/SquidACL_local_functions.ycp Wed Aug 1 13:06:25 2007
@@ -459,5 +459,79 @@
return [tostring(UI::QueryWidget(`id("acl_connections"), `Value))];
}
/*************** MAXCONN END ********************/
+
+
+/*************** HEADER *************************/
+void headerWidgetInit(integer id_item)
+{
+ if (id_item != nil){
+ map acl = Squid::GetACL(id_item);
+ UI::ChangeWidget(`id("acl_header_name"), `Value, (acl["options"]:[])[0]:"");
+ if ((acl["options"]:[])[1]:"" == "-i"){
+ UI::ChangeWidget(`id("acl_regexp"), `Value, (acl["options"]:[])[2]:"");
+ UI::ChangeWidget(`id("acl_regexp_case_insensitive"), `Value, true);
+ }else{
+ UI::ChangeWidget(`id("acl_regexp"), `Value, (acl["options"]:[])[1]:"");
+ }
+ }
+}
+boolean headerVerif()
+{
+ boolean ok = true;
+ string header_name = (string)UI::QueryWidget(`id("acl_header_name"), `Value);
+ string regexp = (string)UI::QueryWidget(`id("acl_regexp"), `Value);
+
+ if (size(header_name) == 0 && size(regexp) == 0){
+ ok = false;
+ Report::Error( _("Header Name and Regular Expression must not be empty."));
+ }
+ return ok;
+}
+list<string> headerOptions()
+{
+ string header_name = (string)UI::QueryWidget(`id("acl_header_name"), `Value);
+ string regexp = (string)UI::QueryWidget(`id("acl_regexp"), `Value);
+ boolean ci = (boolean)UI::QueryWidget(`id("acl_regexp_case_insensitive"), `Value);
+ list <string> ret = [header_name];
+
+ if (ci == true)
+ ret = add(ret, "-i");
+ ret = add(ret, regexp);
+
+ return ret;
+}
+/*************** HEADER END *********************/
+
+
+/*************** ARP ****************************/
+void arpWidgetInit(integer id_item)
+{
+ UI::ChangeWidget(`id("acl_mac"), `ValidChars, "1234567890ABCDEFabcdef:");
+
+ if (id_item != nil){
+ map acl = Squid::GetACL(id_item);
+ UI::ChangeWidget(`id("acl_mac"), `Value, (acl["options"]:[])[0]:"");
+ }
+}
+boolean arpVerif()
+{
+ boolean ok = true;
+ string mac = (string)UI::QueryWidget(`id("acl_mac"), `Value);
+ if (size(mac) == 0){
+ ok = false;
+ Report::Error( _("MAC Address must not be empty."));
+ }else if (!regexpmatch(mac, "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$")){
+ ok = false;
+ Report::Error( _("Incorrect formar of MAC Address."));
+ }
+ return ok;
+}
+list<string> arpOptions()
+{
+ return [(string)UI::QueryWidget(`id("acl_mac"), `Value)];
+}
+/*************** ARP 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=39866&r1=39865&r2=39866&view=diff
==============================================================================
--- trunk/squid/src/complex.ycp (original)
+++ trunk/squid/src/complex.ycp Wed Aug 1 13:06:25 2007
@@ -216,12 +216,16 @@
{
list items = [];
integer i = 0;
+ list<string> sup_acls = SquidACL::SupportedACLs();
foreach(map value, Squid::GetACLs(),
{
- items = add(items, `item(`id(i), value["name"]:"", value["type"]:"",
- mergestring(value["options"]:[], " ")));
- i = i+1;
+ // test, if know how to handle this ACL
+ if (contains(sup_acls, value["type"]:"")){
+ items = add(items, `item(`id(i), value["name"]:"", value["type"]:"",
+ mergestring(value["options"]:[], " ")));
+ i = i+1;
+ }
});
UI::ChangeWidget(`id("acl"), `Items, items);
@@ -249,9 +253,13 @@
if (size(items) > 0){
UI::ChangeWidget(`id(`edit_http_access), `Enabled, true);
UI::ChangeWidget(`id(`del_http_access), `Enabled, true);
+ UI::ChangeWidget(`id(`up_http_access), `Enabled, true);
+ UI::ChangeWidget(`id(`down_http_access), `Enabled, true);
}else{
UI::ChangeWidget(`id(`edit_http_access), `Enabled, false);
UI::ChangeWidget(`id(`del_http_access), `Enabled, false);
+ UI::ChangeWidget(`id(`up_http_access), `Enabled, false);
+ UI::ChangeWidget(`id(`down_http_access), `Enabled, false);
}
}
@@ -308,18 +316,15 @@
boolean StoreDataFromAddEditHttpPortDialog(integer id_item)
{
boolean ok = true;
- map data = $[
- "host" : UI::QueryWidget(`id("host"), `Value),
- "port" : UI::QueryWidget(`id("port"), `Value),
- "transparent" : UI::QueryWidget(`id("transparent"), `Value)
- ];
- y2debug("complex::StoreDataFromAddEditHttpPortDialog() - data: %1",data);
+ string host = (string)UI::QueryWidget(`id("host"), `Value);
+ string port = (string)UI::QueryWidget(`id("port"), `Value);
+ boolean transparent = (boolean)UI::QueryWidget(`id("transparent"), `Value);
- if (size(data["port"]:"") > 0){
+ if (size(port) > 0){
if (id_item == nil){
- Squid::AddHttpPort(data);
+ Squid::AddHttpPort(host, port, transparent);
}else{
- Squid::ModifyHttpPort(id_item, data);
+ Squid::ModifyHttpPort(id_item, host, port, transparent);
}
}else{
Report::Error(_("Port number must not be empty."));
@@ -341,20 +346,17 @@
boolean StoreDataFromAddEditRefreshPatternDialog(integer id_item)
{
boolean ok = true;
- map data = $[
- "regexp" : UI::QueryWidget(`id("regexp"), `Value),
- "min" : tostring(UI::QueryWidget(`id("min"), `Value)),
- "percent" : tostring(UI::QueryWidget(`id("percent"), `Value)),
- "max" : tostring(UI::QueryWidget(`id("max"), `Value)),
- "case_sensitive" : !(boolean)UI::QueryWidget(`id("regexp_case_insensitive"), `Value)
- ];
- y2debug("complex::StoreDataFromAddEditRefreshPatternDialog() - data: %1", data);
+ string regexp = (string)UI::QueryWidget(`id("regexp"), `Value);
+ string min = tostring(UI::QueryWidget(`id("min"), `Value));
+ string percent = tostring(UI::QueryWidget(`id("percent"), `Value));
+ string max = tostring(UI::QueryWidget(`id("max"), `Value));
+ boolean case_sensitive = !(boolean)UI::QueryWidget(`id("regexp_case_insensitive"), `Value);
- if (size(data["regexp"]:"") > 0){
+ if (size(regexp) > 0){
if (id_item == nil){
- Squid::AddRefreshPattern(data);
+ Squid::AddRefreshPattern(regexp, min, percent, max, case_sensitive);
}else{
- Squid::ModifyRefreshPattern(id_item, data);
+ Squid::ModifyRefreshPattern(id_item, regexp, min, percent, max, case_sensitive);
}
}else{
Report::Error(_("Regular expression must not be empty."));
@@ -458,9 +460,9 @@
if (size(acls) > 0){
if (id_item == nil){
- Squid::AddHttpAccess($["allow" : allow, "acl" : acls]);
+ Squid::AddHttpAccess(allow, acls);
}else{
- Squid::ModifyHttpAccess(id_item, $["allow" : allow, "acl" : acls]);
+ Squid::ModifyHttpAccess(id_item, allow, acls);
}
}else{
ok = false;
@@ -502,23 +504,18 @@
boolean StoreDataFromAddEditACLDialog(integer id_item)
{
boolean ok = true;
- map data = $[];
-
string type = (string)UI::QueryWidget(`id("type"), `Value);
string name = (string)UI::QueryWidget(`id("name"), `Value);
+ list<string> options = [];
boolean verification = SquidACL::Verify(type);
if (verification && size(name) > 0){
- data["name"] = name;
- data["type"] = type;
- data["options"] = SquidACL::GetOptions(type);
-
- y2debug("complex::StoreDataFromAddEditACLDialog() - data: %1", data);
+ options = SquidACL::GetOptions(type);
if (id_item == nil){
- Squid::AddACL(data);
+ Squid::AddACL(name, type, options);
}else{
- Squid::ModifyACL(id_item, data);
+ Squid::ModifyACL(id_item, name, type, options);
}
}else if(verification){ // -> size(name) <= 0
ok = false;
Modified: trunk/squid/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/dialogs.ycp?rev=39866&r1=39865&r2=39866&view=diff
==============================================================================
--- trunk/squid/src/dialogs.ycp (original)
+++ trunk/squid/src/dialogs.ycp Wed Aug 1 13:06:25 2007
@@ -38,6 +38,7 @@
//import "Squid";
include "squid/helps.ycp";
+include "squid/popup_dialogs.ycp";
/**
@@ -58,55 +59,6 @@
}
-/**
- * returns true if something added/edited otherwise false
- */
-boolean AddEditHttpPortDialog(integer id_item)
-{
- any ui = nil;
- boolean ret = false;
- string label = (id_item == nil ? _("Add New HTTP Port")
- : _("Edit Current HTTP Port"));
- term contents =
- `VBox(
- `Left(`Label(label)),
- `TextEntry(`id("host"), _("Host"), ""),
- `TextEntry(`id("port"), _("Port"), ""),
- `Frame(_("Options"),
- `VBox(
- `CheckBox(`id("transparent"), "Transparent", false)
- )
- ),
- `VSpacing(),
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton()),
- `PushButton(`id(`ok), Label::OKButton())
- )
- );
-
- UI::OpenDialog(`opt(`decorated), contents);
- UI::ChangeWidget(`id("port"), `ValidChars, "1234567890");
-
- InitAddEditHttpPortDialog(id_item);
-
- while (true){
- ui = UI::UserInput();
-
- if (ui == `abort || ui == `cancel){
- ret = false;
- break;
- }else if (ui == `ok){
- if (StoreDataFromAddEditHttpPortDialog(id_item)){
- ret = true;
- break;
- }
- }
- }
-
- UI::CloseDialog();
- return ret;
-}
-
any HttpPortsDialog(){
@@ -163,62 +115,6 @@
}
-boolean AddEditRefreshPatternDialog(integer id_item)
-{
- boolean ret = false;
- any ui = nil;
- string label = (id_item == nil ? _("Add New Refresh Pattern")
- : _("Edit Current refresh Pattern"));
- term contents =
- `VBox(
- `Left(`Label(label)),
-
- `HBox(
- `TextEntry(`id("regexp"), _("Regular Expression"), ""),
- `CheckBox(`id("regexp_case_insensitive"), _("Case Insensitive"))
- ),
- `HBox(
- `Bottom(`IntField(`id("min"), _("Min"), 0, 99999, 0)),
- `Bottom(`Label(_("minutes")))
- ),
- `HBox(
- `Bottom(`IntField(`id("percent"), _("Percent"), 0, 99999, 0)),
- `Bottom(`Label("%"))
- ),
- `HBox(
- `Bottom(`IntField(`id("max"), _("Max"), 0, 99999, 0)),
- `Bottom(`Label(_("minutes")))
- ),
-
- `VSpacing(),
-
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton()),
- `PushButton(`id(`ok), Label::OKButton())
- )
- );
-
- UI::OpenDialog(`opt(`decorated), contents);
-
- InitAddEditRefreshPatternDialog(id_item);
-
- while (true){
- ui = UI::UserInput();
-
- if (ui == `cancel || ui == `abort){
- ret = false;
- break;
- }else if (ui == `ok){
- if (StoreDataFromAddEditRefreshPatternDialog(id_item)){
- ret = true;
- break;
- }
- }
- }
-
- UI::CloseDialog();
- return ret;
-}
any CacheDialog(){
any ret = nil;
@@ -288,52 +184,6 @@
return ret;
}
-boolean CacheDirAdvancedSettingDialog(){
- boolean ret = false;
- any ui = nil;
- term contents =
- `VBox(
- `Left(`Label( _("Cache Directory Advanced Setting"))),
-
- //`ComboBox(`id("type"), _("Type"), []),
- `HBox(
- `IntField(`id("mbytes"), _("Size"), 1, 99999, 10),
- `Bottom(`Label(_("MB")))
- ),
- `IntField(`id("l1dirs"), _("Level 1 Directories"), 1, 99999, 20),
- `IntField(`id("l2dirs"), _("Level 2 Directories"), 1, 99999, 20),
-
- `VSpacing(),
-
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton()),
- `PushButton(`id(`ok), Label::OKButton())
- )
- );
-
- UI::OpenDialog(contents);
-
-
- InitCacheDirAdvancedSettingDialog();
-
- while (true){
- ui = UI::UserInput();
-
- if (ui == `cancel || ui == `abort){
- ret = false;
- break;
- }else if (ui == `ok){
- if (StoreDataFromCacheDirAdvancedSettingDialog()){
- ret = true;
- break;
- }
- }
- }
-
-
- UI::CloseDialog();
- return ret;
-}
any Cache2Dialog(){
any ret = nil;
@@ -410,162 +260,6 @@
-void addItemToAddEditHttpAccessDialog(boolean not, string item)
-{
- list items = [];
-
- integer i = 0;
- foreach (term value, (list<term>)UI::QueryWidget(`id("acls"), `Items),
- {
- items = add(items, `item(`id(i), value[1]:"", value[2]:""));
- i = i+1;
- });
- items = add(items, `item(`id(i), (not == true ? "not" : ""), item));
- UI::ChangeWidget(`id("acls"), `Items, items);
-}
-integer delItemFromAddEditHttpAccessDialog(integer id_item)
-{
- list items = [];
-
- integer i = 0;
- foreach (term value, (list<term>)UI::QueryWidget(`id("acls"), `Items),
- {
- if (value[0]:nil != `id(id_item)){
- items = add(items, `item(`id(i), value[1]:"", value[2]:""));
- i = i+1;
- }
- });
- UI::ChangeWidget(`id("acls"), `Items, items);
- if (id_item >= size(items)){
- id_item = id_item - 1;
- }
- return id_item;
-}
-boolean AddEditHttpAccessDialog(integer id_item)
-{
- boolean ret = false;
- any ui = nil;
- string acl = "";
- boolean not = false;
- any tmp = nil;
- integer id_acl = 0;
- term contents =
- `VBox(
- `ComboBox(`id("allow_deny"), _("Allow/Deny"),
- [`item(`id("allow"), "allow"), `item(`id("deny"), "deny")]),
-
- //`VSpacing(),
-
- `MinSize(25, 7,
- `Table(`id("acls"), `header(" ", _("ACL")), [])
- ),
- `Left(`PushButton(`id(`del), Label::DeleteButton())),
-
- //`VSpacing(),
-
- `Frame( _("Add ACL"),
- `HBox(
- `CheckBox(`id("acl_not"), _("not")),
- `ComboBox(`id("acl"), "ACL", []),
- `PushButton(`id(`add), Label::AddButton())
- )
- ),
-
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton()),
- `PushButton(`id(`ok), Label::OKButton())
- )
- );
-
- UI::OpenDialog(contents);
-
- InitAddEditHttpAccessDialog(id_item);
-
- while (true){
- ui = UI::UserInput();
-
- if (ui == `cancel || ui == `abort){
- ret = false;
- break;
- }else if (ui == `ok){
- if (StoreDataFromAddEditHttpAccessDialog(id_item)){
- ret = true;
- break;
- }
- }else if (ui == `add){
- acl = (string)UI::QueryWidget(`id("acl"), `Value);
- not = (boolean)UI::QueryWidget(`id("acl_not"), `Value);
- if (size(acl) > 0){
- addItemToAddEditHttpAccessDialog(not, acl);
- InitAddEditHttpAccessDialog(nil);
- }
- }else if (ui == `del){
- id_acl = delItemFromAddEditHttpAccessDialog((integer)UI::QueryWidget(`id("acls"), `CurrentItem));
- InitAddEditHttpAccessDialog(nil);
- UI::ChangeWidget(`id("acls"), `CurrentItem, id_acl);
- }
- }
-
-
- UI::CloseDialog();
-
- return ret;
-}
-
-
-boolean AddEditACLDialog(integer id_item)
-{
- boolean ret = false;
- any ui = nil;
- string orig_type = "";
- string type = "";
- term contents =
- `VBox(
- `TextEntry(`id("name"), _("Name"), ""),
- `ComboBox(`id("type"), `opt(`notify), _("Type"), SquidACL::GetTypesToComboBox()),
- `ReplacePoint(`id(`replace_point), `Empty()),
-
- `HBox(
- `PushButton(`id(`cancel), Label::CancelButton()),
- `PushButton(`id(`ok), Label::OKButton())
- )
- );
-
- UI::OpenDialog(contents);
-
- InitAddEditACLDialog(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();
-
- if (ui == `cancel || ui == `abort){
- ret = false;
- break;
- }else if (ui == `ok){
- if (StoreDataFromAddEditACLDialog(id_item)){
- ret = true;
- break;
- }
- }else if (ui == "type"){
- type = (string)UI::QueryWidget(`id("type"), `Value);
- SquidACL::Replace(`replace_point, type);
- if (type == orig_type){
- SquidACL::InitWidget(type, id_item);
- }else{
- SquidACL::InitWidget(type, nil);
- }
- }
- }
-
-
- UI::CloseDialog();
-
- return ret;
-}
any AccessControlDialog(){
any ret = nil;
integer id_item = nil;
Added: trunk/squid/src/popup_dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/popup_dialogs.ycp?rev=39866&view=auto
==============================================================================
--- trunk/squid/src/popup_dialogs.ycp (added)
+++ trunk/squid/src/popup_dialogs.ycp Wed Aug 1 13:06:25 2007
@@ -0,0 +1,368 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/squid/popup_dialogs.ycp
+ * Package: Configuration of squid
+ * Summary: Popup dialogs definitions
+ * Authors: Daniel Fiser
+ *
+ * $Id$
+ */
+
+{
+
+textdomain "squid";
+
+/***************** HTTP PORT ********************/
+/**
+ * returns true if something added/edited otherwise false
+ */
+boolean AddEditHttpPortDialog(integer id_item)
+{
+ any ui = nil;
+ boolean ret = false;
+ string label = (id_item == nil ? _("Add New HTTP Port")
+ : _("Edit Current HTTP Port"));
+ term contents =
+ `VBox(
+ `Label(label),
+ `VSpacing(0.5),
+ `TextEntry(`id("host"), _("Host"), ""),
+ `TextEntry(`id("port"), _("Port"), ""),
+ `Frame(_("Options"),
+ `VBox(
+ `CheckBox(`id("transparent"), "Transparent", false)
+ )
+ ),
+ `VSpacing(),
+ `VStretch(),
+ `HBox(
+ `PushButton(`id(`cancel), Label::CancelButton()),
+ `PushButton(`id(`ok), Label::OKButton())
+ )
+ );
+
+ UI::OpenDialog(`opt(`decorated), contents);
+ UI::ChangeWidget(`id("port"), `ValidChars, "1234567890");
+
+ InitAddEditHttpPortDialog(id_item);
+
+ while (true){
+ ui = UI::UserInput();
+
+ if (ui == `abort || ui == `cancel){
+ ret = false;
+ break;
+ }else if (ui == `ok){
+ if (StoreDataFromAddEditHttpPortDialog(id_item)){
+ ret = true;
+ break;
+ }
+ }
+ }
+
+ UI::CloseDialog();
+ return ret;
+}
+/***************** HTTP PORT END ****************/
+
+
+/***************** CACHE ************************/
+boolean AddEditRefreshPatternDialog(integer id_item)
+{
+ boolean ret = false;
+ any ui = nil;
+ string label = (id_item == nil ? _("Add New Refresh Pattern")
+ : _("Edit Current refresh Pattern"));
+ term contents =
+ `VBox(
+ `Label(label),
+ `VSpacing(0.5),
+
+ `VSquash(`HBox(
+ `TextEntry(`id("regexp"), _("Regular Expression"), ""),
+ `Bottom(`CheckBox(`id("regexp_case_insensitive"), _("Case Insensitive")))
+ )),
+ `IntField(`id("min"), _("Min (in minutes)"), 0, 99999, 0),
+ `IntField(`id("percent"), _("Percent"), 0, 99999, 0),
+ `IntField(`id("max"), _("Max (in minutes)"), 0, 99999, 0),
+
+ `VSpacing(),
+ `VStretch(),
+
+ `HBox(
+ `PushButton(`id(`cancel), Label::CancelButton()),
+ `PushButton(`id(`ok), Label::OKButton())
+ )
+ );
+
+ UI::OpenDialog(`opt(`decorated), contents);
+
+ InitAddEditRefreshPatternDialog(id_item);
+
+ while (true){
+ ui = UI::UserInput();
+
+ if (ui == `cancel || ui == `abort){
+ ret = false;
+ break;
+ }else if (ui == `ok){
+ if (StoreDataFromAddEditRefreshPatternDialog(id_item)){
+ ret = true;
+ break;
+ }
+ }
+ }
+
+ UI::CloseDialog();
+ return ret;
+}
+
+
+boolean CacheDirAdvancedSettingDialog(){
+ boolean ret = false;
+ any ui = nil;
+ term contents =
+ `VBox(
+ `Label( _("Cache Directory Advanced Setting")),
+ `VSpacing(0.5),
+
+ //`ComboBox(`id("type"), _("Type"), []),
+ `IntField(`id("mbytes"), _("Size (in MB)"), 1, 99999, 10),
+ `IntField(`id("l1dirs"), _("Level 1 Directories"), 1, 99999, 20),
+ `IntField(`id("l2dirs"), _("Level 2 Directories"), 1, 99999, 20),
+
+ `VSpacing(),
+
+ `HBox(
+ `PushButton(`id(`cancel), Label::CancelButton()),
+ `PushButton(`id(`ok), Label::OKButton())
+ )
+ );
+
+ UI::OpenDialog(contents);
+
+
+ InitCacheDirAdvancedSettingDialog();
+
+ while (true){
+ ui = UI::UserInput();
+
+ if (ui == `cancel || ui == `abort){
+ ret = false;
+ break;
+ }else if (ui == `ok){
+ if (StoreDataFromCacheDirAdvancedSettingDialog()){
+ ret = true;
+ break;
+ }
+ }
+ }
+
+
+ UI::CloseDialog();
+ return ret;
+}
+/***************** CACHE END ********************/
+
+
+/***************** ACCESS CONTROL ***************/
+void addItemToAddEditHttpAccessDialog(boolean not, string item)
+{
+ list items = [];
+
+ integer i = 0;
+ foreach (term value, (list<term>)UI::QueryWidget(`id("acls"), `Items),
+ {
+ items = add(items, `item(`id(i), value[1]:"", value[2]:""));
+ i = i+1;
+ });
+ items = add(items, `item(`id(i), (not == true ? "not" : ""), item));
+ UI::ChangeWidget(`id("acls"), `Items, items);
+}
+integer delItemFromAddEditHttpAccessDialog(integer id_item)
+{
+ list items = [];
+
+ integer i = 0;
+ foreach (term value, (list<term>)UI::QueryWidget(`id("acls"), `Items),
+ {
+ if (value[0]:nil != `id(id_item)){
+ items = add(items, `item(`id(i), value[1]:"", value[2]:""));
+ i = i+1;
+ }
+ });
+ UI::ChangeWidget(`id("acls"), `Items, items);
+ if (id_item >= size(items)){
+ id_item = id_item - 1;
+ }
+ return id_item;
+}
+
+
+boolean AddEditHttpAccessDialog(integer id_item)
+{
+ boolean ret = false;
+ any ui = nil;
+ string acl = "";
+ boolean not = false;
+ any tmp = nil;
+ integer id_acl = 0;
+ string label = (id_item == nil ? _("Add New HTTP Access")
+ : _("Edit HTTP Access"));
+ term contents =
+ `VBox(
+ `Label(label),
+ `VSpacing(0.5),
+
+ `Left(`ComboBox(`id("allow_deny"), _("Allow/Deny"),
+ [`item(`id("allow"), "allow"), `item(`id("deny"), "deny")])),
+
+ //`VSpacing(),
+
+ `MinSize(25, 7,
+ `Table(`id("acls"), `header(" ", _("ACL")), [])
+ ),
+ `Left(`PushButton(`id(`del), Label::DeleteButton())),
+
+ //`VSpacing(),
+
+ `Frame( _("Add ACL"),
+ `VSquash(`HBox(
+ `Bottom(`CheckBox(`id("acl_not"), _("not"))),
+ `ComboBox(`id("acl"), "ACL", []),
+ `Bottom(`PushButton(`id(`add), Label::AddButton()))
+ ))
+ ),
+
+ `VStretch(),
+
+ `HBox(
+ `PushButton(`id(`cancel), Label::CancelButton()),
+ `PushButton(`id(`ok), Label::OKButton())
+ )
+ );
+
+ UI::OpenDialog(contents);
+
+ InitAddEditHttpAccessDialog(id_item);
+
+ while (true){
+ ui = UI::UserInput();
+
+ if (ui == `cancel || ui == `abort){
+ ret = false;
+ break;
+ }else if (ui == `ok){
+ if (StoreDataFromAddEditHttpAccessDialog(id_item)){
+ ret = true;
+ break;
+ }
+ }else if (ui == `add){
+ acl = (string)UI::QueryWidget(`id("acl"), `Value);
+ not = (boolean)UI::QueryWidget(`id("acl_not"), `Value);
+ if (size(acl) > 0){
+ addItemToAddEditHttpAccessDialog(not, acl);
+ InitAddEditHttpAccessDialog(nil);
+ }
+ }else if (ui == `del){
+ id_acl = delItemFromAddEditHttpAccessDialog((integer)UI::QueryWidget(`id("acls"), `CurrentItem));
+ InitAddEditHttpAccessDialog(nil);
+ UI::ChangeWidget(`id("acls"), `CurrentItem, id_acl);
+ }
+ }
+
+
+ UI::CloseDialog();
+
+ return ret;
+}
+
+
+boolean AddEditACLDialog(integer id_item)
+{
+ boolean ret = false;
+ any ui = nil;
+ string orig_type = "";
+ string type = "";
+ string label = (id_item == nil ? _("Add New ACL Group")
+ : _("Edit ACL Group"));
+ term contents =
+ `HBox(
+ `HWeight(50, `RichText(`id("help_text"), "Bla bla bla bla bla bla bla bla bla bla bla bla bla bla etc.")),
+ `HWeight(70, `VBox(
+ `Label(label),
+ `VSpacing(0.5),
+
+ `TextEntry(`id("name"), _("Name"), ""),
+ `Left(`ComboBox(`id("type"), `opt(`notify), _("Type"), SquidACL::GetTypesToComboBox())),
+ `ReplacePoint(`id(`replace_point), `Empty()),
+
+ `VStretch(),
+
+ `HBox(
+ `PushButton(`id(`cancel), Label::CancelButton()),
+ `PushButton(`id(`ok), Label::OKButton())
+ )
+ ))
+ );
+
+ UI::OpenDialog(contents);
+
+ InitAddEditACLDialog(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();
+
+ if (ui == `cancel || ui == `abort){
+ ret = false;
+ break;
+ }else if (ui == `ok){
+ if (StoreDataFromAddEditACLDialog(id_item)){
+ ret = true;
+ break;
+ }
+ }else if (ui == "type"){
+ type = (string)UI::QueryWidget(`id("type"), `Value);
+ SquidACL::Replace(`replace_point, type);
+ if (type == orig_type){
+ SquidACL::InitWidget(type, id_item);
+ }else{
+ SquidACL::InitWidget(type, nil);
+ }
+ }
+ }
+
+
+ UI::CloseDialog();
+
+ return ret;
+}
+/***************** ACCESS CONTROL END ***********/
+
+
+
+}
+/* vim: set sw=4 ts=4 et ft=ycp : */
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org