Author: dfiser
Date: Mon Aug 27 13:39:25 2007
New Revision: 40498
URL: http://svn.opensuse.org/viewcvs/yast?rev=40498&view=rev
Log:
Created new file with helper functions and some functions moved there.
Added more checking in input data.
Added:
trunk/squid/src/helper_functions.ycp
Modified:
trunk/squid/src/Makefile.am
trunk/squid/src/SquidACL_local_functions.ycp
trunk/squid/src/dialogs.ycp
trunk/squid/src/helps.ycp
trunk/squid/src/popup_dialogs.ycp
trunk/squid/src/store_del.ycp
Modified: trunk/squid/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/Makefile.am?rev=40498&r1=40497&r2=40498&view=diff
==============================================================================
--- trunk/squid/src/Makefile.am (original)
+++ trunk/squid/src/Makefile.am Mon Aug 27 13:39:25 2007
@@ -14,7 +14,8 @@
complex.ycp \
inits.ycp \
store_del.ycp \
- SquidACL_local_functions.ycp
+ SquidACL_local_functions.ycp \
+ helper_functions.ycp
desktop_DATA = \
squid.desktop
Modified: trunk/squid/src/SquidACL_local_functions.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/SquidACL_local_functions.ycp?rev=40498&r1=40497&r2=40498&view=diff
==============================================================================
--- trunk/squid/src/SquidACL_local_functions.ycp (original)
+++ trunk/squid/src/SquidACL_local_functions.ycp Mon Aug 27 13:39:25 2007
@@ -33,6 +33,8 @@
import "Squid";
+include "squid/helper_functions.ycp";
+
list<string> splitToChars(string str)
{
integer len = size(str);
@@ -46,10 +48,6 @@
return (ret);
}
-boolean isIPAddr(string str)
-{
- return regexpmatch(str, "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$");
-}
boolean isMask(string str)
{
return regexpmatch(str, "^[0-9]+$") || isIPAddr(str);
Modified: trunk/squid/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/dialogs.ycp?rev=40498&r1=40497&r2=40498&view=diff
==============================================================================
--- trunk/squid/src/dialogs.ycp (original)
+++ trunk/squid/src/dialogs.ycp Mon Aug 27 13:39:25 2007
@@ -50,25 +50,6 @@
return false;
}
-/**
- * Returns a widget with setting of units
- */
-term sizeUnitWidget(string id)
-{
- return `ComboBox(`id(id), " ",
- [`item("B"), `item("KB"), `item("MB")]);
-}
-/**
- * Returns a widget with setting of units
- */
-term timeUnitWidget(string id)
-{
- return `ComboBox(`id(id), " ",
- [`item("seconds"), `item("minutes"), `item("hours"), `item("days")]);
-}
-
-
-
any HttpPortsDialog(){
any ret = nil;
@@ -195,6 +176,8 @@
any Cache2Dialog(){
any ret = nil;
string cache_dir = "";
+ any tmp = nil;
+ any tmp2 = nil;
term dialog_contents =
`VCenter( `HBox(
@@ -252,11 +235,11 @@
`Bottom(`PushButton(`id(`browse_cache_dir), Label::BrowseButton()))
)),
`VSpacing(0.4),
- `IntField(`id("mbytes"), _("Size (in MB)"), 0, 99999, 0),
+ `IntField(`id("mbytes"), _("Size (in MB)"), 1, 99999, 1),
`VSpacing(0.4),
- `IntField(`id("l1dirs"), _("Level 1 Directories"), 0, 99999, 0),
+ `IntField(`id("l1dirs"), _("Level 1 Directories"), 1, 99999, 1),
`VSpacing(0.4),
- `IntField(`id("l2dirs"), _("Level 2 Directories"), 0, 99999, 0)
+ `IntField(`id("l2dirs"), _("Level 2 Directories"), 1, 99999, 1)
)
))
),
@@ -266,6 +249,14 @@
Wizard::SetContentsButtons("Squid - Cache Setting 2", dialog_contents, HELPS["cache2"]:"",
Label::BackButton(), Label::NextButton());
+ UI::ChangeWidget(`id("cache_max_object_size"), `Notify, true);
+ UI::ChangeWidget(`id("cache_min_object_size"), `Notify, true);
+ UI::ChangeWidget(`id("cache_max_object_size_units"), `Notify, true);
+ UI::ChangeWidget(`id("cache_min_object_size_units"), `Notify, true);
+
+ UI::ChangeWidget(`id("cache_swap_low"), `Notify, true);
+ UI::ChangeWidget(`id("cache_swap_high"), `Notify, true);
+
InitCache2Dialog();
while (true){
@@ -284,6 +275,36 @@
if (cache_dir != nil){
UI::ChangeWidget(`id("cache_dir"), `Value, cache_dir);
}
+
+ //cache_min_object_size <= cache_max_object_size
+ }else if (ret == "cache_min_object_size" || ret == "cache_min_object_size_units"){
+ tmp = (integer)UI::QueryWidget(`id("cache_min_object_size"), `Value) *
+ unitToMultiple((string)UI::QueryWidget(`id("cache_min_object_size_units"), `Value));
+ tmp2 = (integer)UI::QueryWidget(`id("cache_max_object_size"), `Value) *
+ unitToMultiple((string)UI::QueryWidget(`id("cache_max_object_size_units"), `Value));
+ if ((integer)tmp > (integer)tmp2){
+ UI::ChangeWidget(`id("cache_max_object_size"), `Value, UI::QueryWidget(`id("cache_min_object_size"), `Value));
+ UI::ChangeWidget(`id("cache_max_object_size_units"), `Value, UI::QueryWidget(`id("cache_min_object_size_units"), `Value));
+ }
+ }else if (ret == "cache_max_object_size" || ret == "cache_max_object_size_units"){
+ tmp = (integer)UI::QueryWidget(`id("cache_min_object_size"), `Value) *
+ unitToMultiple((string)UI::QueryWidget(`id("cache_min_object_size_units"), `Value));
+ tmp2 = (integer)UI::QueryWidget(`id("cache_max_object_size"), `Value) *
+ unitToMultiple((string)UI::QueryWidget(`id("cache_max_object_size_units"), `Value));
+ if ((integer)tmp > (integer)tmp2){
+ UI::ChangeWidget(`id("cache_min_object_size"), `Value, UI::QueryWidget(`id("cache_max_object_size"), `Value));
+ UI::ChangeWidget(`id("cache_min_object_size_units"), `Value, UI::QueryWidget(`id("cache_max_object_size_units"), `Value));
+ }
+
+ //cache_swap_low <= cache_swap_high
+ }else if (ret == "cache_swap_low"){
+ tmp = UI::QueryWidget(`id("cache_swap_low"), `Value);
+ if ((integer)tmp > (integer)UI::QueryWidget(`id("cache_swap_high"), `Value))
+ UI::ChangeWidget(`id("cache_swap_high"), `Value, tmp);
+ }else if (ret == "cache_swap_high"){
+ tmp = UI::QueryWidget(`id("cache_swap_high"), `Value);
+ if ((integer)UI::QueryWidget(`id("cache_swap_low"), `Value) > (integer)tmp)
+ UI::ChangeWidget(`id("cache_swap_low"), `Value, tmp);
}
}
Added: trunk/squid/src/helper_functions.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/squid/src/helper_functions.ycp?rev=40498&view=auto
==============================================================================
--- trunk/squid/src/helper_functions.ycp (added)
+++ trunk/squid/src/helper_functions.ycp Mon Aug 27 13:39:25 2007
@@ -0,0 +1,112 @@
+/* ------------------------------------------------------------------------------
+ * 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/helper_functions.ycp
+ * Package: Configuration of squid
+ * Summary: Helper functions for various situations.
+ * Authors: Daniel Fiser