Author: jdsn
Date: Fri Nov 9 19:10:34 2007
New Revision: 41948
URL: http://svn.opensuse.org/viewcvs/yast?rev=41948&view=rev
Log:
more stuff
Modified:
branches/tmp/jdsn/edu-users/src/EduUsers.ycp
branches/tmp/jdsn/edu-users/src/dialogs.ycp
Modified: branches/tmp/jdsn/edu-users/src/EduUsers.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/edu-users/src/EduUsers.ycp?rev=41948&r1=41947&r2=41948&view=diff
==============================================================================
--- branches/tmp/jdsn/edu-users/src/EduUsers.ycp (original)
+++ branches/tmp/jdsn/edu-users/src/EduUsers.ycp Fri Nov 9 19:10:34 2007
@@ -19,10 +19,10 @@
*/
/**
- * File: modules/EduUsers.ycp
- * Package: Configuration of edu-users
- * Summary: EduUsers settings, input and output functions
- * Authors: J. Daniel Schmidt
+ * File: modules/EduUsers.ycp
+ * Package: Configuration of edu-users
+ * Summary: EduUsers settings, input and output functions
+ * Authors: J. Daniel Schmidt
*
* $Id: EduUsers.ycp 27914 2006-02-13 14:32:08Z locilka $
*
@@ -79,7 +79,7 @@
global define boolean Abort() ``{
if(AbortFunction != nil)
{
- return AbortFunction () == true;
+ return AbortFunction () == true;
}
return false;
}
@@ -96,19 +96,34 @@
// ------------------------------------
/**
- * List of the configured cards.
- */
+ * list of terms to hold the users
+ */
+//global list<term> table_users = []; // `item(`id("login"), "Name", "Surname", "Login", "Age", "Password")
+global map allusers = $[];
+
+/**
+ * list of terms to hold the groups
+ */
+//global list<term> table_groups = []; // `item(`id("groupname"), "group name", "template name")
+global list<string> allgroups = [];
+
+/**
+ * list of terms to hold the templates
+ */
+//global list<term> table_templates = []; // `item(`id(0), "template name")
+global list<string> alltemplates = [];
-// list of terms to hold the users to be created
-global list<term> table_users = []; // `item(`id("login"), "Name", "Surname", "Login", "Age", "Password")
-global list<term> table_users_show = []; // `item(`id("login"), "Name", "Surname", "Login", "Age")
-global list<term> table_groups = []; // `item(`id("groupname"), "group name", "template name")
-global list<term> table_templates = []; // `item(`id(0), "template name")
+// global list<term> table_users_show = []; // `item(`id("login"), "Name", "Surname", "Login", "Age")
-global string autologin = "";
+
+global string autologin = ""; // FIXME - how did I want to use this
// TODO FIXME function to return the show table dynamically - do not store twice!
+
+
+// only these characters are allowed in template or group names
+string validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
/**
@@ -118,114 +133,45 @@
global boolean Read() {
/* EduUsers read dialog caption */
- string caption = _("Initializing edu-users Configuration");
-
- integer steps = 5;
- // FIXME: read sysconfig, read users, read groups, read templates
-
+ string caption = _("Initializing Edu Users Configuration");
- integer sl = 50;
- sleep(sl);
+ integer steps = 2;
- // We do not set help text here, because it was set outside
Progress::New( caption, " ", steps, [
- /* Progress stage 1/4 */
- _("Read the database"),
- /* Progress stage 2/4 */
- _("Read Edu users"),
- /* Progress stage 3/4 */
- _("Read Edu groups"),
- /* Progress stage 4/4 */
- _("Read Edu templates")
- ], [
- /* Progress step 1/4 */
- _("Reading the database..."),
- /* Progress step 2/4 */
- _("Reading Edu users..."),
- /* Progress step 2/4 */
- _("Reading Edu groups..."),
- /* Progress step 3/4 */
- _("Reading Edu templates..."),
- /* Progress finished */
- _("Finished")
- ],
- ""
+ /* Progress stage 1 */
+ _("Read the settings")
+ ], [
+ /* Progress step 1 */
+ _("Reading the settings..."),
+ /* Progress finished */
+ _("Finished")
+ ],
+ ""
);
- // read sysconfig
+ // --- READ PROCESS
+
+ /* read sysconfig */
if(Abort()) return false;
Progress::NextStage();
-/*
- string gettemplates = (string) SCR::Read(.sysconfig.educlient.TEMPLATES);
- list<string> alltemplates = splitstring(gettemplates, ", ");
-
- // only these characters are allowed in template or group names
- string validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
-
- integer count=0;
- foreach (string str, alltemplates,
- {
- string strmod = filterchars ( str, validChars );
- if ( strmod != nil && size(strmod) > 0 )
- {
- table_templates = add(table_templates, (term)`item(`id(strmod), strmod ) );
- //count = count+1; // needed in case the id changes back to integer
- }
- });
-
- string getgroups = (string) SCR::Read(.sysconfig.educlient.GROUPS);
- list<string> allgroups = splitstring(getgroups, ", ");
-
- count=0;
- foreach (string str, allgroups,
- {
- list<string> grp_tmpl = splitstring(str, ":");
- if ( ! contains( [1 , 2], size(grp_tmpl) ) ) { continue; }
- // add one element, so that we have two in any case
- grp_tmpl = add(grp_tmpl, "");
-
- grp_tmpl[0] = filterchars ( grp_tmpl[0]:"err", validChars );
- grp_tmpl[1] = filterchars ( grp_tmpl[1]:"err", validChars );
- if ( grp_tmpl[1]:"err"==nil ) { grp_tmpl[1]=""; }
-
- table_groups = add(table_groups, (term)`item(`id(count), grp_tmpl[0]:"err", grp_tmpl[1]:"err" ) );
- count=count+1;
- });
+ string gettemplates = (string) SCR::Read(.sysconfig.educlient.TEMPLATES);
+ alltemplates = splitstring(gettemplates, ", ");
+ string getgroups = (string) SCR::Read(.sysconfig.educlient.GROUPS);
+ allgroups = splitstring(getgroups, ", ");
-*/
-
+ // TODO read user data
+ // addusers = something
/* Error message */
- if(false) Report::Error(_("Cannot read database1."));
- sleep(sl);
+ if(false) Report::Error(_("Cannot read settings."));
- // read another database
- if(Abort()) return false;
- Progress::NextStep();
- /* Error message */
- if(false) Report::Error(_("Cannot read database2."));
- sleep(sl);
-
- // read current settings
- if(Abort()) return false;
- Progress::NextStage();
- /* Error message */
- if(false) Report::Error(Message::CannotReadCurrentSettings());
- sleep(sl);
-
- // detect devices
- if(Abort()) return false;
- Progress::NextStage();
- /* Error message */
- if(false) Report::Warning(_("Cannot detect devices."));
- sleep(sl);
+ sleep(1000);
if(Abort()) return false;
/* Progress finished */
Progress::NextStage();
- sleep(sl);
if(Abort()) return false;
modified = false;
@@ -233,6 +179,64 @@
}
/**
+ * get table of templates
+ * @return table of templates
+ */
+global list<term> getTemplateItems()
+{
+ //integer count=0;
+ list<term> table_templates = [];
+
+ foreach (string str, alltemplates,
+ {
+ string strmod = filterchars ( str, validChars );
+ if ( strmod != nil && size(strmod) > 0 )
+ {
+ table_templates = add(table_templates, (term)`item(`id(strmod), strmod ) );
+ //count = count+1; // needed in case the id changes back to integer
+ }
+ });
+
+ return table_templates;
+}
+
+/**
+ * get table of groups
+ * @return table of groups
+ */
+global list<term> getGroupItems()
+{
+ integer count=0;
+ list<term> table_groups = [];
+ foreach (string str, allgroups,
+ {
+ list<string> grp_tmpl = splitstring(str, ":");
+ if ( ! contains( [1 , 2], size(grp_tmpl) ) ) { continue; }
+ // add one element, so that we have two in any case
+ grp_tmpl = add(grp_tmpl, "");
+
+ grp_tmpl[0] = filterchars ( grp_tmpl[0]:"err", validChars );
+ grp_tmpl[1] = filterchars ( grp_tmpl[1]:"err", validChars );
+ if ( grp_tmpl[1]:"err"==nil ) { grp_tmpl[1]=""; }
+
+ table_groups = add(table_groups, (term)`item(`id(count), grp_tmpl[0]:"err", grp_tmpl[1]:"err" ) );
+ count=count+1;
+ });
+
+ return table_groups;
+}
+
+/**
+ * get table of users
+ * @return table of users
+ */
+global list<term> getUserItems() {
+ return [];
+ // return table_users;
+ // `item(`id("login"), "Name", "Surname", "Login", "Age", "Password")
+}
+
+/**
* Write all edu-users settings
* @return true on success
*/
@@ -250,19 +254,19 @@
// TODO FIXME Names of real stages
// We do not set help text here, because it was set outside
Progress::New(caption, " ", steps, [
- /* Progress stage 1/2 */
- _("Write the settings"),
- /* Progress stage 2/2 */
- _("Run SuSEconfig")
- ], [
- /* Progress step 1/2 */
- _("Writing the settings..."),
- /* Progress step 2/2 */
- _("Running SuSEconfig..."),
- /* Progress finished */
- _("Finished")
- ],
- ""
+ /* Progress stage 1/2 */
+ _("Write the settings"),
+ /* Progress stage 2/2 */
+ _("Run SuSEconfig")
+ ], [
+ /* Progress step 1/2 */
+ _("Writing the settings..."),
+ /* Progress step 2/2 */
+ _("Running SuSEconfig..."),
+ /* Progress finished */
+ _("Finished")
+ ],
+ ""
);
// write settings
Modified: branches/tmp/jdsn/edu-users/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/edu-users/src/dialogs.ycp?rev=41948&r1=41947&r2=41948&view=diff
==============================================================================
--- branches/tmp/jdsn/edu-users/src/dialogs.ycp (original)
+++ branches/tmp/jdsn/edu-users/src/dialogs.ycp Fri Nov 9 19:10:34 2007
@@ -35,6 +35,8 @@
import "Wizard";
import "EduUsers";
import "Autologin";
+import "Users";
+import "UsersCache";
include "edu-users/helps.ycp";
@@ -48,10 +50,12 @@
string caption = _("Add New Edu User");
term fields = `VBox(
+ // text entry
+ `TextEntry (`id(`cn), _("User's &Full Name"), ""),
`VSquash(
`HBox(
// input field for login name
- `Bottom(`TextEntry(`id(`username), _("&Username"), "bla")),
+ `Bottom(`TextEntry(`id(`username), _("&Username"), "")),
("add_user" != "add_user")
? `HSpacing (0)
// push button to generate login from first and last name
@@ -80,7 +84,7 @@
/* EduUsers configure1 dialog contents */
- term contents = `VBox(`Label (_("First part of configuration of edu-users")), `PushButton(`id(`groups), "bla"));
+ term contents = `VBox(`Label (_("First part of configuration of edu-users")), `PushButton(`id(`groups), ""));
contents = `VBox (
`VSpacing(),
@@ -103,19 +107,35 @@
Wizard::SetContentsButtons(caption, contents, HELPS["c1"]:"",
Label::BackButton(), Label::NextButton());
+ string cn = (string) UI::QueryWidget(`id(`cn), `Value);
+ // for proposing username
+ string tmp_cn = cn;
+ UsersCache::ResetProposing ();
+
any ret = nil;
while(true) {
- ret = UI::UserInput();
+ ret = UI::UserInput();
- /* abort? */
- if(ret == `abort || ret == `cancel) {
- if(ReallyAbort()) break;
- else continue;
- }
+ /* abort? */
+ if(ret == `abort || ret == `cancel) {
+ if(ReallyAbort()) break;
+ else continue;
+ }
else if(ret == `next || ret == `back) {
break;
}
+ if (ret == `propose)
+ { // propose a username - sometimes lxuser is the first proposal, no idea why, should be last one
+ cn = (string) UI::QueryWidget(`id(`cn), `Value);
+ if (tmp_cn != cn)
+ {
+ UsersCache::ResetProposing();
+ tmp_cn = cn;
+ }
+ string username = UsersCache::ProposeUsername ( filterchars (cn, Users::ValidLognameChars() + " "));
+ UI::ChangeWidget(`id(`username), `Value, username);
+ }
else {
y2error("unexpected retcode: %1", ret);
continue;
@@ -128,6 +148,7 @@
any UsersDialog() {
+ SetTabDialog();
// fill table with data
Popup::Notify(_("Users"));
@@ -166,10 +187,14 @@
any GroupsDialog() {
-
+
// fill table with data
Popup::Notify(_("Groups"));
+ list<term> groups = EduUsers::getGroupItems();
+
+ UI::ReplaceWidget(`id(`tabContent), `Table( `id(`edutable), `opt(`notify, `vstretch) , `header( _("Groups") ), groups ) );
+
any ret = nil;
while(true) {
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org