Commit 872b8949 authored by claes's avatar claes

Functionality to show volumes and users added

parent 89c60dbb
......@@ -20,6 +20,7 @@
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Xm/ToggleB.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
......@@ -27,6 +28,7 @@
#include <X11/cursorfont.h>
extern "C" {
#include "pwr_privilege.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
......@@ -229,6 +231,215 @@ void Admin::adminprop_setup( char *title, int projname_edit, int base_edit,
XtSetValues( adminprop_dia, args, 2);
}
void Admin::adminuser_setup( char *title, int username_edit, int password_edit,
int system_edit, int priv_edit,
char *username_value, char *system_value, unsigned int priv_value)
{
Arg args[4];
XmString cstr;
Arg sensitive[1];
if ( username_edit)
{
XtUnmanageChild( adminuser_username_noe);
XtManageChild( adminuser_username);
XmTextSetString( adminuser_username, username_value);
}
else
{
XtManageChild( adminuser_username_noe);
XtUnmanageChild( adminuser_username);
XtSetArg(args[0],XmNlabelString,
cstr=XmStringCreateLtoR(username_value , "ISO8859-1"));
XtSetValues( adminuser_username_noe, args, 1);
XmStringFree( cstr);
}
if ( password_edit)
{
XtManageChild( adminuser_password);
XmTextSetString( adminuser_password, "");
}
else
{
XtUnmanageChild( adminuser_password);
}
if ( system_edit)
{
XtUnmanageChild( adminuser_system_noe);
XtManageChild( adminuser_system);
XmTextSetString( adminuser_system, system_value);
}
else
{
XtManageChild( adminuser_system_noe);
XtUnmanageChild( adminuser_system);
XtSetArg(args[0],XmNlabelString,
cstr=XmStringCreateLtoR(system_value , "ISO8859-1"));
XtSetValues( adminuser_system_noe, args, 1);
XmStringFree( cstr);
}
XmToggleButtonSetState( adminuser_priv_rtread, (priv_value & pwr_mPrv_RtRead) != 0, 0);
XmToggleButtonSetState( adminuser_priv_rtwrite, (priv_value & pwr_mPrv_RtWrite) != 0, 0);
XmToggleButtonSetState( adminuser_priv_system, (priv_value & pwr_mPrv_System) != 0, 0);
XmToggleButtonSetState( adminuser_priv_maintenance, (priv_value & pwr_mPrv_Maintenance) != 0, 0);
XmToggleButtonSetState( adminuser_priv_process, (priv_value & pwr_mPrv_Process) != 0, 0);
XmToggleButtonSetState( adminuser_priv_instrument, (priv_value & pwr_mPrv_Instrument) != 0, 0);
XmToggleButtonSetState( adminuser_priv_operator1, (priv_value & pwr_mPrv_Operator1) != 0, 0);
XmToggleButtonSetState( adminuser_priv_operator2, (priv_value & pwr_mPrv_Operator2) != 0, 0);
XmToggleButtonSetState( adminuser_priv_operator3, (priv_value & pwr_mPrv_Operator3) != 0, 0);
XmToggleButtonSetState( adminuser_priv_operator4, (priv_value & pwr_mPrv_Operator4) != 0, 0);
XmToggleButtonSetState( adminuser_priv_operator5, (priv_value & pwr_mPrv_Operator5) != 0, 0);
XmToggleButtonSetState( adminuser_priv_operator6, (priv_value & pwr_mPrv_Operator6) != 0, 0);
XmToggleButtonSetState( adminuser_priv_operator7, (priv_value & pwr_mPrv_Operator7) != 0, 0);
XmToggleButtonSetState( adminuser_priv_operator8, (priv_value & pwr_mPrv_Operator8) != 0, 0);
XmToggleButtonSetState( adminuser_priv_operator9, (priv_value & pwr_mPrv_Operator9) != 0, 0);
XmToggleButtonSetState( adminuser_priv_operator10, (priv_value & pwr_mPrv_Operator10) != 0, 0);
XmToggleButtonSetState( adminuser_priv_devread, (priv_value & pwr_mPrv_DevRead) != 0, 0);
XmToggleButtonSetState( adminuser_priv_devplc, (priv_value & pwr_mPrv_DevPlc) != 0, 0);
XmToggleButtonSetState( adminuser_priv_devconfig, (priv_value & pwr_mPrv_DevConfig) != 0, 0);
XmToggleButtonSetState( adminuser_priv_devclass, (priv_value & pwr_mPrv_DevClass) != 0, 0);
if ( priv_edit)
XtSetArg( sensitive[0],XmNsensitive, 1);
else
XtSetArg( sensitive[0],XmNsensitive, 0);
XtSetValues( adminuser_priv_rtread, sensitive, 1);
XtSetValues( adminuser_priv_rtwrite, sensitive, 1);
XtSetValues( adminuser_priv_system, sensitive, 1);
XtSetValues( adminuser_priv_maintenance, sensitive, 1);
XtSetValues( adminuser_priv_process, sensitive, 1);
XtSetValues( adminuser_priv_instrument, sensitive, 1);
XtSetValues( adminuser_priv_operator1, sensitive, 1);
XtSetValues( adminuser_priv_operator2, sensitive, 1);
XtSetValues( adminuser_priv_operator3, sensitive, 1);
XtSetValues( adminuser_priv_operator4, sensitive, 1);
XtSetValues( adminuser_priv_operator5, sensitive, 1);
XtSetValues( adminuser_priv_operator6, sensitive, 1);
XtSetValues( adminuser_priv_operator7, sensitive, 1);
XtSetValues( adminuser_priv_operator8, sensitive, 1);
XtSetValues( adminuser_priv_operator9, sensitive, 1);
XtSetValues( adminuser_priv_operator10, sensitive, 1);
XtSetValues( adminuser_priv_devread, sensitive, 1);
XtSetValues( adminuser_priv_devplc, sensitive, 1);
XtSetValues( adminuser_priv_devconfig, sensitive, 1);
XtSetValues( adminuser_priv_devclass, sensitive, 1);
XtSetArg(args[0],XmNtitle, title);
XtSetValues( XtParent(adminuser_dia), args, 1);
XtSetArg(args[0],XmNwidth, 400);
XtSetArg(args[1],XmNheight, 650);
XtSetValues( adminuser_dia, args, 2);
}
void Admin::adminsys_setup( char *title, int systemname_edit, int attr_edit,
char *systemname_value, unsigned int attr_value)
{
Arg args[4];
XmString cstr;
Arg sensitive[1];
if ( systemname_edit)
{
XtUnmanageChild( adminsys_systemname_noe);
XtManageChild( adminsys_systemname);
XmTextSetString( adminsys_systemname, systemname_value);
}
else
{
XtManageChild( adminsys_systemname_noe);
XtUnmanageChild( adminsys_systemname);
XtSetArg(args[0],XmNlabelString,
cstr=XmStringCreateLtoR(systemname_value , "ISO8859-1"));
XtSetValues( adminsys_systemname_noe, args, 1);
XmStringFree( cstr);
}
XmToggleButtonSetState( adminsys_attr_userinherit, (attr_value & user_mSystemAttr_UserInherit) != 0, 0);
if ( attr_edit)
XtSetArg( sensitive[0],XmNsensitive, 1);
else
XtSetArg( sensitive[0],XmNsensitive, 0);
XtSetValues( adminsys_attr_userinherit, sensitive, 1);
XtSetArg(args[0],XmNtitle, title);
XtSetValues( XtParent(adminsys_dia), args, 1);
XtSetArg(args[0],XmNwidth, 400);
XtSetArg(args[1],XmNheight, 350);
XtSetValues( adminsys_dia, args, 2);
}
void Admin::adminvol_setup( char *title, int volumename_edit, int volumeid_edit,
int projectname_edit, char *volumename_value, char *volumeid_value,
char *projectname_value)
{
XmString cstr;
Arg args[4];
if ( volumename_edit)
{
XtUnmanageChild( adminvol_volumename_noe);
XtManageChild( adminvol_volumename);
XmTextSetString( adminvol_volumename, volumename_value);
}
else
{
XtManageChild( adminvol_volumename_noe);
XtUnmanageChild( adminvol_volumename);
XtSetArg(args[0],XmNlabelString,
cstr=XmStringCreateLtoR(volumename_value , "ISO8859-1"));
XtSetValues( adminvol_volumename_noe, args, 1);
XmStringFree( cstr);
}
if ( volumeid_edit)
{
XtUnmanageChild( adminvol_volumeid_noe);
XtManageChild( adminvol_volumeid);
XmTextSetString( adminvol_volumeid, volumeid_value);
}
else
{
XtManageChild( adminvol_volumeid_noe);
XtUnmanageChild( adminvol_volumeid);
XtSetArg(args[0],XmNlabelString,
cstr=XmStringCreateLtoR(volumeid_value , "ISO8859-1"));
XtSetValues( adminvol_volumeid_noe, args, 1);
XmStringFree( cstr);
}
if ( projectname_edit)
{
XtUnmanageChild( adminvol_projname_noe);
XtManageChild( adminvol_projname);
XmTextSetString( adminvol_projname, projectname_value);
}
else
{
XtManageChild( adminvol_projname_noe);
XtUnmanageChild( adminvol_projname);
XtSetArg(args[0],XmNlabelString,
cstr=XmStringCreateLtoR(projectname_value , "ISO8859-1"));
XtSetValues( adminvol_projname_noe, args, 1);
XmStringFree( cstr);
}
XtSetArg(args[0],XmNtitle, title);
XtSetValues( XtParent(adminvol_dia), args, 1);
XtSetArg(args[0],XmNwidth, 400);
XtSetArg(args[1],XmNheight, 200);
XtSetValues( adminvol_dia, args, 2);
}
void Admin::set_prompt( char *prompt)
{
Arg args[3];
......@@ -242,6 +453,59 @@ void Admin::set_prompt( char *prompt)
XmStringFree( cstr);
}
extern "C" void admin_delete_volume_ok( void *ctx, void *data)
{
Admin *admin = (Admin *)ctx;
Item *item = (Item *)data;
int sts;
((AdminNav *)admin->adminnav)->volumes_delete( item->get_node());
sts = ((AdminNav *)admin->adminnav)->volumes_save();
if ( EVEN(sts)) {
wow_DisplayError( admin->adminvol_dia, "Remove volume",
"Unable to open file $pwra_db/pwr_volumelist.dat");
((AdminNav *)admin->adminnav)->refresh();
return;
}
}
extern "C" void admin_delete_user_ok( void *ctx, void *data)
{
Admin *admin = (Admin *)ctx;
ItemUser *item = (ItemUser *)data;
int sts;
char system_name[80];
SystemList *system = ((AdminNav *)admin->adminnav)->gu->get_system( item->user);
if ( !system) return;
((AdminNav *)admin->adminnav)->gu->get_system_name( system, system_name);
sts = ((AdminNav *)admin->adminnav)->gu->remove_user( system_name, item->user->get_name());
if ( EVEN(sts)) {
admin->message( 'E', ((AdminNav *)admin->adminnav)->gu->get_status( sts));
return;
}
((AdminNav *)admin->adminnav)->gu->save();
((AdminNav *)admin->adminnav)->refresh();
}
extern "C" void admin_delete_system_ok( void *ctx, void *data)
{
Admin *admin = (Admin *)ctx;
ItemUsersGroup *item = (ItemUsersGroup *)data;
int sts;
char system_name[80];
((AdminNav *)admin->adminnav)->gu->get_system_name( item->group, system_name);
sts = ((AdminNav *)admin->adminnav)->gu->remove_system( system_name);
if ( EVEN(sts)) {
admin->message( 'E', ((AdminNav *)admin->adminnav)->gu->get_status( sts));
return;
}
((AdminNav *)admin->adminnav)->gu->save();
((AdminNav *)admin->adminnav)->refresh();
}
int Admin::open_project()
{
Item *base_item;
......@@ -266,18 +530,18 @@ int Admin::open_project()
system( cmd);
break;
}
case adminnav_eItemType_Db:
case adminnav_eItemType_ProjDb:
{
ItemDb *item = (ItemDb *)base_item;
ItemProjDb *item = (ItemProjDb *)base_item;
sprintf( cmd, "wb_admin.sh opendb %s \"%s\" \"%s\" %s", item->project,
login_prv.username, login_prv.password, item->db);
system( cmd);
break;
}
case adminnav_eItemType_Volume:
case adminnav_eItemType_ProjVolume:
{
ItemVolume *item = (ItemVolume *)base_item;
ItemProjVolume *item = (ItemProjVolume *)base_item;
sprintf( cmd, "wb_admin.sh opendb %s \"%s\" \"%s\" %s %s", item->project,
login_prv.username, login_prv.password, item->db,
......@@ -472,6 +736,189 @@ int Admin::project_properties(int projname_edit, int base_edit,
return 1;
}
int Admin::user_properties( admin_eDiaUserFunction function, int username_edit, int password_edit,
int system_edit, int priv_edit)
{
int sts;
Item *base_item;
switch ( function) {
case admin_eDiaUserFunction_Prop:
sts = ((AdminNav *)adminnav)->get_select( (void **) &base_item);
if ( EVEN(sts)) {
message('E', "Select a user");
return 0;
}
switch ( base_item->type){
case adminnav_eItemType_User: {
ItemUser *item = (ItemUser *)base_item;
char system_name[80];
SystemList *system = ((AdminNav *)adminnav)->gu->get_system( item->user);
((AdminNav *)adminnav)->gu->get_system_name( system, system_name);
adminuser_setup( "User properties", username_edit, password_edit,
system_edit, priv_edit,
item->user->get_name(), system_name, item->user->get_priv());
diauser_function = admin_eDiaUserFunction_Prop;
XtManageChild( adminuser_dia);
break;
}
default:
message('E', "Select a user");
}
case admin_eDiaUserFunction_New:
sts = ((AdminNav *)adminnav)->get_select( (void **) &base_item);
if ( EVEN(sts)) {
message('E', "Select a systemgroup");
return 0;
}
switch ( base_item->type){
case adminnav_eItemType_UsersGroup: {
ItemUsersGroup *item = (ItemUsersGroup *)base_item;
char system_name[80];
((AdminNav *)adminnav)->gu->get_system_name( item->group, system_name);
adminuser_setup( "User properties", username_edit, password_edit,
system_edit, priv_edit, "", system_name, 0);
diauser_function = admin_eDiaUserFunction_New;
XtManageChild( adminuser_dia);
break;
}
default:
message('E', "Select a systemgroup");
}
break;
}
return 1;
}
int Admin::system_properties( admin_eDiaSysFunction function, int systemname_edit, int attr_edit)
{
int sts;
Item *base_item;
switch ( function) {
case admin_eDiaSysFunction_Prop:
sts = ((AdminNav *)adminnav)->get_select( (void **) &base_item);
if ( EVEN(sts)) {
message('E', "Select a systemgroup");
return 0;
}
switch ( base_item->type){
case adminnav_eItemType_UsersGroup: {
ItemUsersGroup *item = (ItemUsersGroup *)base_item;
char system_name[80];
((AdminNav *)adminnav)->gu->get_system_name( item->group, system_name);
adminsys_setup( "System group properties", systemname_edit, attr_edit,
system_name, item->group->get_attributes());
diasys_function = admin_eDiaSysFunction_Prop;
XtManageChild( adminsys_dia);
break;
}
default:
message('E', "Select a system group");
}
case admin_eDiaSysFunction_New: {
char system_name[80];
sts = ((AdminNav *)adminnav)->get_select( (void **) &base_item);
if ( ODD(sts)) {
switch ( base_item->type){
case adminnav_eItemType_UsersGroup: {
ItemUsersGroup *item = (ItemUsersGroup *)base_item;
((AdminNav *)adminnav)->gu->get_system_name( item->group, system_name);
strcat( system_name, ".");
break;
}
default:
message('E', "Select a system group");
return 0;
}
}
else
strcpy( system_name, "");
adminsys_setup( "System group properties", systemname_edit, attr_edit, system_name, 0);
diasys_function = admin_eDiaSysFunction_New;
XtManageChild( adminsys_dia);
break;
}
}
return 1;
}
int Admin::volume_properties( admin_eDiaVolFunction function, int volumename_edit,
int volumeid_edit, int projectname_edit)
{
int sts;
Item *base_item;
switch ( function) {
case admin_eDiaVolFunction_Prop:
sts = ((AdminNav *)adminnav)->get_select( (void **) &base_item);
if ( EVEN(sts)) {
message('E', "Select a volume");
return 0;
}
switch ( base_item->type){
case adminnav_eItemType_Volume: {
ItemVolume *item = (ItemVolume *)base_item;
char volumeid[80];
strcpy( volumeid, cdh_VolumeIdToString( NULL, item->vid, 0, 0));
adminvol_setup( "Volume properties", volumename_edit, volumeid_edit,
projectname_edit, item->name, volumeid, item->project);
adminvol_item = base_item;
diavol_function = admin_eDiaVolFunction_Prop;
XtManageChild( adminvol_dia);
break;
}
default:
message('E', "Select a volume");
}
break;
case admin_eDiaVolFunction_New: {
sts = ((AdminNav *)adminnav)->get_select( (void **) &base_item);
if ( ODD(sts))
adminvol_item = base_item;
else
adminvol_item = 0;
adminvol_setup( "Volume properties", volumename_edit, volumeid_edit,
projectname_edit, "", "", "");
diavol_function = admin_eDiaVolFunction_New;
XtManageChild( adminvol_dia);
break;
}
}
return 1;
}
static void admin_valchanged_cmd_input( Widget w, XEvent *event)
{
Admin *admin;
......@@ -523,6 +970,9 @@ int Admin::open_input()
else
XmTextSetString( text_w, "");
if ( value)
XtFree( value);
message( ' ', "");
flow_SetInputFocus( text_w);
set_prompt( "admin >");
......@@ -554,7 +1004,7 @@ static void admin_activate_createproject( Widget w, Admin *admin, XmAnyCallbackS
{
if ( !admin->edit_mode)
{
admin->message('E', "Not authorized for this operation");
admin->message('E', "Not edit mode");
return;
}
admin->create_project();
......@@ -564,7 +1014,7 @@ static void admin_activate_deleteproject( Widget w, Admin *admin, XmAnyCallbackS
{
if ( !admin->edit_mode)
{
admin->message('E', "Not authorized for this operation");
admin->message('E', "Not edit mode");
return;
}
admin->delete_project();
......@@ -574,7 +1024,7 @@ static void admin_activate_copyproject( Widget w, Admin *admin, XmAnyCallbackStr
{
if ( !admin->edit_mode)
{
admin->message('E', "Not authorized for this operation");
admin->message('E', "Not edit mode");
return;
}
admin->copy_project();
......@@ -584,7 +1034,7 @@ static void admin_activate_renameproject( Widget w, Admin *admin, XmAnyCallbackS
{
if ( !admin->edit_mode)
{
admin->message('E', "Not authorized for this operation");
admin->message('E', "Not edit mode");
return;
}
admin->project_properties(1,0,0,0,0);
......@@ -594,7 +1044,7 @@ static void admin_activate_moveproject( Widget w, Admin *admin, XmAnyCallbackStr
{
if ( !admin->edit_mode)
{
admin->message('E', "Not authorized for this operation");
admin->message('E', "Not edit mode");
return;
}
admin->project_properties(0,0,1,0,0);
......@@ -608,6 +1058,120 @@ static void admin_activate_projectprop( Widget w, Admin *admin, XmAnyCallbackStr
admin->project_properties(0,1,0,1,1);
}
static void admin_activate_volumeprop( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
if ( !admin->edit_mode)
admin->volume_properties( admin_eDiaVolFunction_Prop, 0,0,0);
else
admin->volume_properties( admin_eDiaVolFunction_Prop, 1,1,1);
}
static void admin_activate_newvolume( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
if ( !admin->edit_mode)
admin->message('E', "Not edit mode");
else
admin->volume_properties( admin_eDiaVolFunction_New, 1,1,1);
}
static void admin_activate_removevolume( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
Item *item;
int sts;
char text[200];
if ( !admin->edit_mode) {
admin->message('E', "Not edit mode");
return;
}
sts = ((AdminNav *)admin->adminnav)->get_select( (void **) &item);
if ( EVEN(sts) || !( item->type == adminnav_eItemType_Volume)) {
admin->message('E', "Select a volume");
return;
}
sprintf( text, "Do you wan't to remove volume %s\n", item->identity());
wow_DisplayQuestion( (void *)admin, admin->toplevel, "Remove volume", text,
admin_delete_volume_ok, NULL, item);
}
static void admin_activate_userprop( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
if ( !admin->edit_mode)
admin->user_properties( admin_eDiaUserFunction_Prop, 0,0,0,0);
else
admin->user_properties( admin_eDiaUserFunction_Prop, 0,1,0,1);
}
static void admin_activate_newuser( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
if ( !admin->edit_mode)
admin->message('E', "Not edit mode");
else
admin->user_properties( admin_eDiaUserFunction_New, 1,1,0,1);
}
static void admin_activate_removeuser( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
ItemUser *item;
char text[200];
int sts;
if ( !admin->edit_mode) {
admin->message('E', "Not edit mode");
return;
}
sts = ((AdminNav *)admin->adminnav)->get_select( (void **) &item);
if ( EVEN(sts) || item->type != adminnav_eItemType_User) {
admin->message('E', "Select a user");
return;
}
sprintf( text, "Do you wan't to remove user %s\n", item->identity());
wow_DisplayQuestion( (void *)admin, admin->toplevel, "Remove user", text,
admin_delete_user_ok, NULL, item);
}
static void admin_activate_systemprop( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
if ( !admin->edit_mode)
admin->system_properties( admin_eDiaSysFunction_Prop, 0,0);
else
admin->system_properties( admin_eDiaSysFunction_Prop, 0,1);
}
static void admin_activate_newsystem( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
if ( !admin->edit_mode)
admin->message('E', "Not edit mode");
else
admin->system_properties( admin_eDiaSysFunction_New, 1,1);
}
static void admin_activate_removesystem( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
ItemUsersGroup *item;
char text[200];
int sts;
if ( !admin->edit_mode) {
admin->message('E', "Not edit mode");
return;
}
sts = ((AdminNav *)admin->adminnav)->get_select( (void **) &item);
if ( EVEN(sts) || item->type != adminnav_eItemType_UsersGroup) {
admin->message('E', "Select a system group");
return;
}
sprintf( text, "Do you wan't to remove user %s\n", item->identity());
wow_DisplayQuestion( (void *)admin, admin->toplevel, "Remove system grou", text,
admin_delete_system_ok, NULL, item);
}
static void admin_activate_exit( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
if ( admin->close_cb)
......@@ -646,6 +1210,58 @@ static void admin_activate_print( Widget w, Admin *admin, XmAnyCallbackStruct *d
admin->message('I', msg);
}
static void admin_activate_edit( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
if ( admin->edit_mode) {
admin->edit_mode = 0;
admin->message('I', "Leaving edit mode");
XmToggleButtonSetState( admin->menu_edit, 0, 0);
}
else {
if ( !admin->loggedin) {
admin->message('E', "Not authorized to enter edit");
XmToggleButtonSetState( admin->menu_edit, 0, 0);
return;
}
admin->edit_mode = 1;
admin->message('I', "Entering edit mode");
XmToggleButtonSetState( admin->menu_edit, 1, 0);
}
}
static void admin_activate_viewprojects( Widget w, Admin *admin, XmToggleButtonCallbackStruct *data)
{
if ( data->set) {
((AdminNav *)admin->adminnav)->view( adminnav_eMode_Projects);
XtUnmanageChild( admin->volume_entry);
XtUnmanageChild( admin->user_entry);
XtManageChild( admin->proj_entry);
admin->set_title( "PwR Project Administrator");
}
}
static void admin_activate_viewvolumes( Widget w, Admin *admin, XmToggleButtonCallbackStruct *data)
{
if ( data->set) {
((AdminNav *)admin->adminnav)->view( adminnav_eMode_Volumes);
XtUnmanageChild( admin->proj_entry);
XtUnmanageChild( admin->user_entry);
XtManageChild( admin->volume_entry);
admin->set_title( "PwR Volume Administrator");
}
}
static void admin_activate_viewusers( Widget w, Admin *admin, XmToggleButtonCallbackStruct *data)
{
if ( data->set) {
((AdminNav *)admin->adminnav)->view( adminnav_eMode_Users);
XtUnmanageChild( admin->volume_entry);
XtUnmanageChild( admin->proj_entry);
XtManageChild( admin->user_entry);
admin->set_title( "PwR User Administrator");
}
}
static void admin_activate_zoomin( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
double zoom_factor;
......@@ -703,6 +1319,31 @@ static void admin_create_adminnav_form( Widget w, Admin *admin, XmAnyCallbackStr
admin->adminnav_form = w;
}
static void admin_create_proj_entry( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->proj_entry = w;
}
static void admin_create_volume_entry( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->volume_entry = w;
}
static void admin_create_user_entry( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->user_entry = w;
}
static void admin_create_menu_project( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->menu_project = w;
}
static void admin_create_menu_edit( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->menu_edit = w;
}
static void adminprop_create_projnamevalue( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminprop_projname = w;
......@@ -943,6 +1584,462 @@ static void adminprop_activate_cancel( Widget w, Admin *admin, XmAnyCallbackStru
XtUnmanageChild( admin->adminprop_dia);
}
// User dialog callbacks
static void adminuser_create_usernamevalue( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_username = w;
}
static void adminuser_create_passwordvalue( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_password = w;
}
static void adminuser_create_systemvalue( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_system = w;
}
static void adminuser_create_userna_noedit( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_username_noe = w;
}
static void adminuser_create_system_noedit( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_system_noe = w;
}
static void adminuser_create_rtread( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_rtread = w;
}
static void adminuser_create_rtwrite( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_rtwrite = w;
}
static void adminuser_create_system( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_system = w;
}
static void adminuser_create_maintenance( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_maintenance = w;
}
static void adminuser_create_process( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_process = w;
}
static void adminuser_create_instrument( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_instrument = w;
}
static void adminuser_create_operator1( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_operator1 = w;
}
static void adminuser_create_operator2( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_operator2 = w;
}
static void adminuser_create_operator3( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_operator3 = w;
}
static void adminuser_create_operator4( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_operator4 = w;
}
static void adminuser_create_operator5( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_operator5 = w;
}
static void adminuser_create_operator6( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_operator6 = w;
}
static void adminuser_create_operator7( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_operator7 = w;
}
static void adminuser_create_operator8( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_operator8 = w;
}
static void adminuser_create_operator9( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_operator9 = w;
}
static void adminuser_create_operator10( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_operator10 = w;
}
static void adminuser_create_devread( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_devread = w;
}
static void adminuser_create_devplc( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_devplc = w;
}
static void adminuser_create_devconfig( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_devconfig = w;
}
static void adminuser_create_devclass( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminuser_priv_devclass = w;
}
static void adminuser_activate_ok( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
char *username;
char *password;
unsigned int priv = 0;
int sts;
char old_password[80];
unsigned int old_priv;
if ( !admin->edit_mode) {
XtUnmanageChild( admin->adminuser_dia);
return;
}
if ( XmToggleButtonGetState( admin->adminuser_priv_rtread))
priv |= pwr_mPrv_RtRead;
if ( XmToggleButtonGetState( admin->adminuser_priv_rtwrite))
priv |= pwr_mPrv_RtWrite;
if ( XmToggleButtonGetState( admin->adminuser_priv_system))
priv |= pwr_mPrv_System;
if ( XmToggleButtonGetState( admin->adminuser_priv_maintenance))
priv |= pwr_mPrv_Maintenance;
if ( XmToggleButtonGetState( admin->adminuser_priv_process))
priv |= pwr_mPrv_Process;
if ( XmToggleButtonGetState( admin->adminuser_priv_instrument))
priv |= pwr_mPrv_Instrument;
if ( XmToggleButtonGetState( admin->adminuser_priv_operator1))
priv |= pwr_mPrv_Operator1;
if ( XmToggleButtonGetState( admin->adminuser_priv_operator2))
priv |= pwr_mPrv_Operator2;
if ( XmToggleButtonGetState( admin->adminuser_priv_operator3))
priv |= pwr_mPrv_Operator3;
if ( XmToggleButtonGetState( admin->adminuser_priv_operator4))
priv |= pwr_mPrv_Operator4;
if ( XmToggleButtonGetState( admin->adminuser_priv_operator5))
priv |= pwr_mPrv_Operator5;
if ( XmToggleButtonGetState( admin->adminuser_priv_operator6))
priv |= pwr_mPrv_Operator6;
if ( XmToggleButtonGetState( admin->adminuser_priv_operator7))
priv |= pwr_mPrv_Operator7;
if ( XmToggleButtonGetState( admin->adminuser_priv_operator8))
priv |= pwr_mPrv_Operator8;
if ( XmToggleButtonGetState( admin->adminuser_priv_operator9))
priv |= pwr_mPrv_Operator9;
if ( XmToggleButtonGetState( admin->adminuser_priv_operator10))
priv |= pwr_mPrv_Operator10;
if ( XmToggleButtonGetState( admin->adminuser_priv_devread))
priv |= pwr_mPrv_DevRead;
if ( XmToggleButtonGetState( admin->adminuser_priv_devplc))
priv |= pwr_mPrv_DevPlc;
if ( XmToggleButtonGetState( admin->adminuser_priv_devconfig))
priv |= pwr_mPrv_DevConfig;
if ( XmToggleButtonGetState( admin->adminuser_priv_devclass))
priv |= pwr_mPrv_DevClass;
switch ( admin->diauser_function) {
case admin_eDiaUserFunction_Prop: {
char username_label[80];
char system_label[80];
wow_GetLabel( admin->adminuser_username_noe, username_label);
wow_GetLabel( admin->adminuser_system_noe, system_label);
password = XmTextGetString( admin->adminuser_password);
if ( strcmp( username_label, "") == 0) {
wow_DisplayError( admin->adminuser_dia, "Modify user error",
"Username is missing");
return;
}
if ( strcmp( system_label, "") == 0) {
wow_DisplayError( admin->adminuser_dia, "Modify user error",
"Systemgroup is missing");
return;
}
sts = ((AdminNav *)admin->adminnav)->gu->get_user_data( system_label, username_label, old_password, &old_priv);
if ( EVEN(sts)) {
wow_DisplayError( admin->adminuser_dia, "Modify user error",
((AdminNav *)admin->adminnav)->gu->get_status( sts));
return;
}
if ( strcmp( password, "") == 0)
password = old_password;
sts = ((AdminNav *)admin->adminnav)->gu->modify_user( system_label, username_label, password, priv);
if ( EVEN(sts)) {
wow_DisplayError( admin->adminuser_dia, "Modify user error",
((AdminNav *)admin->adminnav)->gu->get_status( sts));
return;
}
((AdminNav *)admin->adminnav)->gu->save();
break;
}
case admin_eDiaUserFunction_New: {
char system_label[80];
wow_GetLabel( admin->adminuser_system_noe, system_label);
username = XmTextGetString( admin->adminuser_username);
password = XmTextGetString( admin->adminuser_password);
if ( strcmp( username, "") == 0) {
wow_DisplayError( admin->adminuser_dia, "New user error",
"Username is missing");
return;
}
if ( strcmp( password, "") == 0) {
wow_DisplayError( admin->adminuser_dia, "New user error",
"Password is missing");
return;
}
if ( strcmp( system_label, "") == 0) {
wow_DisplayError( admin->adminuser_dia, "New user error",
"Systemgroup is missing");
return;
}
sts = ((AdminNav *)admin->adminnav)->gu->add_user( system_label, username, password, priv);
if ( EVEN(sts)) {
wow_DisplayError( admin->adminuser_dia, "New user error",
((AdminNav *)admin->adminnav)->gu->get_status( sts));
return;
}
((AdminNav *)admin->adminnav)->gu->save();
((AdminNav *)admin->adminnav)->refresh();
break;
}
}
XtUnmanageChild( admin->adminuser_dia);
}
static void adminuser_activate_cancel( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
XtUnmanageChild( admin->adminuser_dia);
}
//
// Systemgroup dia callbacks
//
static void adminsys_create_systemnamevalue( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminsys_systemname = w;
}
static void adminsys_create_systemna_noedit( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminsys_systemname_noe = w;
}
static void adminsys_create_userinherit( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminsys_attr_userinherit = w;
}
static void adminsys_activate_ok( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
char *systemname;
unsigned int attr = 0;
int sts;
if ( !admin->edit_mode) {
XtUnmanageChild( admin->adminsys_dia);
return;
}
if ( XmToggleButtonGetState( admin->adminsys_attr_userinherit))
attr |= user_mSystemAttr_UserInherit;
switch ( admin->diasys_function) {
case admin_eDiaSysFunction_Prop: {
char systemname_label[80];
wow_GetLabel( admin->adminsys_systemname_noe, systemname_label);
if ( strcmp( systemname_label, "") == 0) {
wow_DisplayError( admin->adminsys_dia, "Modify systemgroup error",
"Systemgroup name is missing");
return;
}
sts = ((AdminNav *)admin->adminnav)->gu->modify_system( systemname_label, attr);
if ( EVEN(sts)) {
wow_DisplayError( admin->adminsys_dia, "Modify systemgroup error",
((AdminNav *)admin->adminnav)->gu->get_status( sts));
return;
}
((AdminNav *)admin->adminnav)->gu->save();
break;
}
case admin_eDiaSysFunction_New: {
systemname = XmTextGetString( admin->adminsys_systemname);
if ( strcmp( systemname, "") == 0) {
wow_DisplayError( admin->adminsys_dia, "New systemgroup error",
"Systemgroup name is missing");
return;
}
sts = ((AdminNav *)admin->adminnav)->gu->add_system( systemname, attr);
if ( EVEN(sts)) {
wow_DisplayError( admin->adminsys_dia, "New systemgroup error",
((AdminNav *)admin->adminnav)->gu->get_status( sts));
return;
}
((AdminNav *)admin->adminnav)->gu->save();
((AdminNav *)admin->adminnav)->refresh();
break;
}
}
XtUnmanageChild( admin->adminsys_dia);
}
static void adminsys_activate_cancel( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
XtUnmanageChild( admin->adminsys_dia);
}
//
// Volume dia callbacks
//
static void adminvol_create_volumenamevalue( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminvol_volumename = w;
}
static void adminvol_create_volumena_noedit( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminvol_volumename_noe = w;
}
static void adminvol_create_volumeidvalue( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminvol_volumeid = w;
}
static void adminvol_create_volumeid_noedit( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminvol_volumeid_noe = w;
}
static void adminvol_create_projnamevalue( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminvol_projname = w;
}
static void adminvol_create_projna_noedit( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
admin->adminvol_projname_noe = w;
}
static void adminvol_activate_ok( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
char *volumename;
char *volumeid;
char *projectname;
pwr_tVolumeId volid;
int sts;
if ( !admin->edit_mode) {
XtUnmanageChild( admin->adminvol_dia);
return;
}
switch ( admin->diavol_function) {
case admin_eDiaVolFunction_Prop: {
volumename = XmTextGetString( admin->adminvol_volumename);
volumeid = XmTextGetString( admin->adminvol_volumeid);
projectname = XmTextGetString( admin->adminvol_projname);
if ( strcmp( volumename, "") == 0) {
wow_DisplayError( admin->adminvol_dia, "Modify volume error",
"Volume name is missing");
return;
}
if ( strcmp( projectname, "") == 0) {
wow_DisplayError( admin->adminvol_dia, "Modify volume error",
"Project name is missing");
return;
}
sts = cdh_StringToVolumeId( volumeid, &volid);
if ( EVEN(sts)) {
wow_DisplayError( admin->adminvol_dia, "Modify volume error",
"Syntax error in volume id");
return;
}
((ItemVolume *)admin->adminvol_item)->modify( volumename, volumeid, projectname);
sts = ((AdminNav *)admin->adminnav)->volumes_save();
if ( EVEN(sts)) {
wow_DisplayError( admin->adminvol_dia, "Modify volume",
"Unable to open file $pwra_db/pwr_volumelist.dat");
return;
}
break;
}
case admin_eDiaSysFunction_New: {
volumename = XmTextGetString( admin->adminvol_volumename);
volumeid = XmTextGetString( admin->adminvol_volumeid);
projectname = XmTextGetString( admin->adminvol_projname);
if ( strcmp( volumename, "") == 0) {
wow_DisplayError( admin->adminvol_dia, "New volume error",
"Volume name is missing");
return;
}
if ( strcmp( projectname, "") == 0) {
wow_DisplayError( admin->adminvol_dia, "New volume error",
"Project name is missing");
return;
}
sts = cdh_StringToVolumeId( volumeid, &volid);
if ( EVEN(sts)) {
wow_DisplayError( admin->adminvol_dia, "New volume error",
"Syntax error in volume id");
return;
}
if ( !admin->adminvol_item)
sts = ((AdminNav *)admin->adminnav)->volumes_add( volumename, volumeid, projectname,
0, flow_eDest_IntoLast);
else
sts = ((AdminNav *)admin->adminnav)->volumes_add( volumename, volumeid, projectname,
admin->adminvol_item->get_node(), flow_eDest_After);
if ( EVEN(sts)) {
wow_DisplayError( admin->adminvol_dia, "New volume",
"Volume id or volumename is not unic");
return;
}
sts = ((AdminNav *)admin->adminnav)->volumes_save();
if ( EVEN(sts)) {
wow_DisplayError( admin->adminvol_dia, "New volume",
"Unable to open file $pwra_db/pwr_volumelist.dat");
return;
}
break;
}
}
XtUnmanageChild( admin->adminvol_dia);
}
static void adminvol_activate_cancel( Widget w, Admin *admin, XmAnyCallbackStruct *data)
{
XtUnmanageChild( admin->adminvol_dia);
}
static void admin_enable_set_focus( Admin *admin)
{
admin->set_focus_disabled--;
......@@ -981,6 +2078,13 @@ static void admin_action_inputfocus( Widget w, XmAnyCallbackStruct *data)
admin_disable_set_focus( admin, 400);
}
void Admin::set_title( char *title)
{
Arg args[1];
XtSetArg(args[0],XmNtitle, title);
XtSetValues( parent_wid, args, 1);
}
Admin::~Admin()
{
......@@ -999,7 +2103,7 @@ Admin::Admin(
input_open(0), close_cb(0), set_focus_disabled(0),
cmd_current_recall(0),
ccm_func_registred(0), verify(0), scriptmode(0), edit_mode(0),
clock_cursor(0)
clock_cursor(0), loggedin(0)
{
char uid_filename[120] = {"pwr_exe:wb_admin.uid"};
char *uid_filename_p = uid_filename;
......@@ -1022,7 +2126,13 @@ Admin::Admin(
static MrmRegisterArg reglist[] = {
{ "admin_ctx", 0 },
{"admin_create_proj_entry",(caddr_t)admin_create_proj_entry },
{"admin_create_volume_entry",(caddr_t)admin_create_volume_entry },
{"admin_create_user_entry",(caddr_t)admin_create_user_entry },
{"admin_create_menu_edit",(caddr_t)admin_create_menu_edit },
{"admin_create_menu_project",(caddr_t)admin_create_menu_project },
{"admin_activate_exit",(caddr_t)admin_activate_exit },
{"admin_activate_edit",(caddr_t)admin_activate_edit },
{"admin_activate_refresh",(caddr_t)admin_activate_refresh },
{"admin_activate_print",(caddr_t)admin_activate_print },
{"admin_activate_command",(caddr_t)admin_activate_command },
......@@ -1033,6 +2143,18 @@ Admin::Admin(
{"admin_activate_moveproject",(caddr_t)admin_activate_moveproject },
{"admin_activate_renameproject",(caddr_t)admin_activate_renameproject },
{"admin_activate_projectprop",(caddr_t)admin_activate_projectprop },
{"admin_activate_volumeprop",(caddr_t)admin_activate_volumeprop },
{"admin_activate_newvolume",(caddr_t)admin_activate_newvolume },
{"admin_activate_removevolume",(caddr_t)admin_activate_removevolume },
{"admin_activate_userprop",(caddr_t)admin_activate_userprop },
{"admin_activate_newuser",(caddr_t)admin_activate_newuser },
{"admin_activate_removeuser",(caddr_t)admin_activate_removeuser },
{"admin_activate_systemprop",(caddr_t)admin_activate_systemprop },
{"admin_activate_newsystem",(caddr_t)admin_activate_newsystem },
{"admin_activate_removesystem",(caddr_t)admin_activate_removesystem },
{"admin_activate_viewprojects",(caddr_t)admin_activate_viewprojects },
{"admin_activate_viewvolumes",(caddr_t)admin_activate_viewvolumes },
{"admin_activate_viewusers",(caddr_t)admin_activate_viewusers },
{"admin_activate_zoomin",(caddr_t)admin_activate_zoomin },
{"admin_activate_zoomout",(caddr_t)admin_activate_zoomout },
{"admin_activate_zoomreset",(caddr_t)admin_activate_zoomreset },
......@@ -1052,7 +2174,47 @@ Admin::Admin(
{"adminprop_create_base_noedit",(caddr_t)adminprop_create_base_noedit },
{"adminprop_create_path_noedit",(caddr_t)adminprop_create_path_noedit },
{"adminprop_create_hier_noedit",(caddr_t)adminprop_create_hier_noedit },
{"adminprop_create_descr_noedit",(caddr_t)adminprop_create_descr_noedit }
{"adminprop_create_descr_noedit",(caddr_t)adminprop_create_descr_noedit },
{"adminuser_activate_ok",(caddr_t)adminuser_activate_ok },
{"adminuser_activate_cancel",(caddr_t)adminuser_activate_cancel },
{"adminuser_create_usernamevalue",(caddr_t)adminuser_create_usernamevalue },
{"adminuser_create_passwordvalue",(caddr_t)adminuser_create_passwordvalue },
{"adminuser_create_systemvalue",(caddr_t)adminuser_create_systemvalue },
{"adminuser_create_userna_noedit",(caddr_t)adminuser_create_userna_noedit },
{"adminuser_create_system_noedit",(caddr_t)adminuser_create_system_noedit },
{"adminuser_create_rtread",(caddr_t)adminuser_create_rtread },
{"adminuser_create_rtwrite",(caddr_t)adminuser_create_rtwrite },
{"adminuser_create_system",(caddr_t)adminuser_create_system },
{"adminuser_create_maintenance",(caddr_t)adminuser_create_maintenance },
{"adminuser_create_process",(caddr_t)adminuser_create_process },
{"adminuser_create_instrument",(caddr_t)adminuser_create_instrument },
{"adminuser_create_operator1",(caddr_t)adminuser_create_operator1 },
{"adminuser_create_operator2",(caddr_t)adminuser_create_operator2 },
{"adminuser_create_operator3",(caddr_t)adminuser_create_operator3 },
{"adminuser_create_operator4",(caddr_t)adminuser_create_operator4 },
{"adminuser_create_operator5",(caddr_t)adminuser_create_operator5 },
{"adminuser_create_operator6",(caddr_t)adminuser_create_operator6 },
{"adminuser_create_operator7",(caddr_t)adminuser_create_operator7 },
{"adminuser_create_operator8",(caddr_t)adminuser_create_operator8 },
{"adminuser_create_operator9",(caddr_t)adminuser_create_operator9 },
{"adminuser_create_operator10",(caddr_t)adminuser_create_operator10 },
{"adminuser_create_devread",(caddr_t)adminuser_create_devread },
{"adminuser_create_devplc",(caddr_t)adminuser_create_devplc },
{"adminuser_create_devconfig",(caddr_t)adminuser_create_devconfig },
{"adminuser_create_devclass",(caddr_t)adminuser_create_devclass },
{"adminsys_activate_ok",(caddr_t)adminsys_activate_ok },
{"adminsys_activate_cancel",(caddr_t)adminsys_activate_cancel },
{"adminsys_create_systemnamevalue",(caddr_t)adminsys_create_systemnamevalue },
{"adminsys_create_systemna_noedit",(caddr_t)adminsys_create_systemna_noedit },
{"adminsys_create_userinherit",(caddr_t)adminsys_create_userinherit },
{"adminvol_activate_ok",(caddr_t)adminvol_activate_ok },
{"adminvol_activate_cancel",(caddr_t)adminvol_activate_cancel },
{"adminvol_create_volumenamevalue",(caddr_t)adminvol_create_volumenamevalue },
{"adminvol_create_volumena_noedit",(caddr_t)adminvol_create_volumena_noedit },
{"adminvol_create_volumeidvalue",(caddr_t)adminvol_create_volumeidvalue },
{"adminvol_create_volumeid_noedit",(caddr_t)adminvol_create_volumeid_noedit },
{"adminvol_create_projnamevalue",(caddr_t)adminvol_create_projnamevalue },
{"adminvol_create_projna_noedit",(caddr_t)adminvol_create_projna_noedit }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
......@@ -1090,8 +2252,19 @@ Admin::Admin(
&adminprop_dia, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch input dialog\n");
MrmCloseHierarchy(s_DRMh);
sts = MrmFetchWidget(s_DRMh, "adminuser_dia", parent_wid,
&adminuser_dia, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch input dialog\n");
sts = MrmFetchWidget(s_DRMh, "adminsys_dia", parent_wid,
&adminsys_dia, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch input dialog\n");
sts = MrmFetchWidget(s_DRMh, "adminvol_dia", parent_wid,
&adminvol_dia, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch input dialog\n");
MrmCloseHierarchy(s_DRMh);
if (compiled_translations == NULL)
XtAppAddActions( XtWidgetToApplicationContext(toplevel),
......@@ -1113,6 +2286,11 @@ Admin::Admin(
&brow_widget, &sts);
((AdminNav *)adminnav)->message_cb = &admin_message_cb;
set_title( "PwR Project Administrator");
XtUnmanageChild( volume_entry);
XtUnmanageChild( user_entry);
XmToggleButtonSetState( menu_project, 1, 0);
XtPopup( parent_wid, XtGrabNone);
// Connect the window manager close-button to exit
......@@ -1121,3 +2299,11 @@ Admin::Admin(
}
......@@ -26,6 +26,21 @@ typedef enum {
admin_eDiaFunction_Prop
} admin_eDiaFunction;
typedef enum {
admin_eDiaUserFunction_New,
admin_eDiaUserFunction_Prop
} admin_eDiaUserFunction;
typedef enum {
admin_eDiaSysFunction_New,
admin_eDiaSysFunction_Prop
} admin_eDiaSysFunction;
typedef enum {
admin_eDiaVolFunction_New,
admin_eDiaVolFunction_Prop
} admin_eDiaVolFunction;
class Admin {
public:
Admin(
......@@ -43,6 +58,12 @@ class Admin {
Widget cmd_prompt;
Widget cmd_input;
Widget adminnav_form;
Widget proj_entry;
Widget volume_entry;
Widget user_entry;
Widget menu_project;
Widget menu_edit;
Widget adminprop_dia;
Widget adminprop_projname;
Widget adminprop_base;
......@@ -54,6 +75,47 @@ class Admin {
Widget adminprop_path_noe;
Widget adminprop_hier_noe;
Widget adminprop_descript_noe;
Widget adminuser_dia;
Widget adminuser_username;
Widget adminuser_password;
Widget adminuser_system;
Widget adminuser_username_noe;
Widget adminuser_system_noe;
Widget adminuser_priv_rtread;
Widget adminuser_priv_rtwrite;
Widget adminuser_priv_system;
Widget adminuser_priv_maintenance;
Widget adminuser_priv_process;
Widget adminuser_priv_instrument;
Widget adminuser_priv_operator1;
Widget adminuser_priv_operator2;
Widget adminuser_priv_operator3;
Widget adminuser_priv_operator4;
Widget adminuser_priv_operator5;
Widget adminuser_priv_operator6;
Widget adminuser_priv_operator7;
Widget adminuser_priv_operator8;
Widget adminuser_priv_operator9;
Widget adminuser_priv_operator10;
Widget adminuser_priv_devread;
Widget adminuser_priv_devplc;
Widget adminuser_priv_devconfig;
Widget adminuser_priv_devclass;
Widget adminsys_dia;
Widget adminsys_systemname;
Widget adminsys_systemname_noe;
Widget adminsys_attr_userinherit;
Widget adminvol_dia;
Widget adminvol_volumename;
Widget adminvol_volumename_noe;
Widget adminvol_volumeid;
Widget adminvol_volumeid_noe;
Widget adminvol_projname;
Widget adminvol_projname_noe;
int input_open;
void *object;
void (*close_cb) ( void *);
......@@ -62,6 +124,9 @@ class Admin {
int set_focus_disabled;
XtIntervalId focus_timerid;
int dia_function;
int diauser_function;
int diasys_function;
int diavol_function;
char copy_from_proj[80];
char modify_projname[120];
char modify_base[120];
......@@ -80,9 +145,12 @@ class Admin {
int scriptmode;
int edit_mode;
int clock_cursor;
Item *adminvol_item;
int loggedin;
void message( char severity, char *message);
void set_prompt( char *prompt);
void set_title( char *title);
int open_input();
int open_project();
int create_project();
......@@ -90,10 +158,23 @@ class Admin {
int copy_project();
int project_properties(int projname_edit, int base_edit,
int path_edit, int hier_edit, int descr_edit);
int user_properties( admin_eDiaUserFunction function, int username_edit, int password_edit,
int system_edit, int priv_edit);
int system_properties( admin_eDiaSysFunction function, int systemname_edit, int attr_edit);
int volume_properties( admin_eDiaVolFunction function, int volumename_edit,
int volumeid_edit, int projectname_edit);
void adminprop_setup( char *title, int projname_edit, int base_edit,
int path_edit, int hier_edit, int descript_edit,
char *projname_value, char *base_value, char *path_value,
char *hier_value, char *descript_value);
void adminuser_setup( char *title, int username_edit, int password_edit,
int system_edit, int priv_edit,
char *username_value, char *system_value, unsigned int priv_value);
void adminsys_setup( char *title, int systemname_edit, int attr_edit,
char *systemname_value, unsigned int attr_value);
void adminvol_setup( char *title, int volumename_edit, int volumeid_edit,
int projectname_edit, char *volumename_value, char *volumeidvalue,
char *projectnamevalue);
void set_clock_cursor();
void reset_cursor();
void set_clock_cursor_dia();
......
......@@ -119,7 +119,7 @@ static int admin_login_func( void *client_data,
if ( EVEN(sts))
{
// Username and password are not required
admin->edit_mode = 1;
admin->loggedin = 1;
admin->message('I', "Administrator logged in");
return 1;
}
......@@ -142,7 +142,7 @@ static int admin_login_func( void *client_data,
admin->message('E',"Login failure");
else
{
admin->edit_mode = 1;
admin->loggedin = 1;
sprintf( msg, "User %s logged in", arg1_str);
admin->message('I', msg);
}
......@@ -154,10 +154,10 @@ static int admin_logout_func( void *client_data,
{
Admin *admin = (Admin *)client_data;
if ( admin->edit_mode)
if ( admin->loggedin)
{
admin->message('I', "Administrator logged out");
admin->edit_mode = 0;
admin->loggedin = 0;
}
else
admin->message('I', "Not logged in");
......
......@@ -61,7 +61,8 @@ AdminNav::AdminNav(
parent_ctx(xn_parent_ctx), parent_wid(xn_parent_wid),
trace_started(0),
message_cb(NULL), set_focus_cb(NULL),
menu_tree(NULL), baselist(NULL), displayed(0)
proj_menu_tree(NULL), baselist(NULL), displayed(0),
mode(adminnav_eMode_Projects), gu(0)
{
strcpy( name, xn_name);
......@@ -87,6 +88,71 @@ AdminNav::~AdminNav()
XtDestroyWidget( form_widget);
}
void AdminNav::view( adminnav_eMode m)
{
if ( m == mode)
return;
switch( m) {
case adminnav_eMode_Volumes:
switch( mode) {
case adminnav_eMode_Projects:
proj_tree_free();
brow_DeleteAll( brow->ctx);
volumes_tree_build();
mode = m;
break;
case adminnav_eMode_Users:
users_tree_free();
brow_DeleteAll( brow->ctx);
volumes_tree_build();
mode = m;
break;
default:
;
}
break;
case adminnav_eMode_Projects:
switch( mode) {
case adminnav_eMode_Volumes:
volumes_tree_free();
brow_DeleteAll( brow->ctx);
proj_tree_build();
mode = m;
break;
case adminnav_eMode_Users:
users_tree_free();
brow_DeleteAll( brow->ctx);
proj_tree_build();
mode = m;
break;
default:
;
}
break;
case adminnav_eMode_Users:
switch( mode) {
case adminnav_eMode_Volumes:
volumes_tree_free();
brow_DeleteAll( brow->ctx);
users_tree_build();
mode = m;
break;
case adminnav_eMode_Projects:
proj_tree_free();
brow_DeleteAll( brow->ctx);
users_tree_build();
mode = m;
break;
default:
;
}
break;
default:
;
}
}
//
// Print
//
......@@ -148,7 +214,7 @@ void AdminNav::set_inputfocus( int focus)
static int adminnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
{
AdminNav *adminnav;
ItemProjHier *item;
Item *item;
if ( event->event == flow_eEvent_ObjectDeleted)
{
......@@ -288,20 +354,8 @@ static int adminnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
break;
brow_GetUserData( node_list[0], (void **)&item);
free( node_list);
switch( item->type)
{
case adminnav_eItemType_ProjHier:
((ItemProjHier *)item)->open_children( adminnav, 0, 0);
break;
case adminnav_eItemType_Project:
((ItemProject *)item)->open_children( adminnav, 0, 0);
break;
case adminnav_eItemType_Db:
((ItemDb *)item)->open_children( adminnav, 0, 0);
break;
default:
;
}
item->open_children( adminnav, 0, 0);
break;
}
case flow_eEvent_Key_PF4:
......@@ -326,20 +380,9 @@ static int adminnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
break;
}
brow_GetUserData( object, (void **)&item);
switch( item->type)
{
case adminnav_eItemType_ProjHier:
((ItemProjHier *)item)->close( adminnav, 0, 0);
break;
case adminnav_eItemType_Project:
((ItemProject *)item)->close( adminnav, 0, 0);
break;
case adminnav_eItemType_Db:
((ItemDb *)item)->close( adminnav, 0, 0);
break;
default:
;
}
item->close( adminnav, 0, 0);
brow_SelectClear( adminnav->brow->ctx);
brow_SetInverse( object, 1);
brow_SelectInsert( adminnav->brow->ctx, object);
......@@ -353,23 +396,9 @@ static int adminnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
{
case flow_eObjectType_Node:
brow_GetUserData( event->object.object, (void **)&item);
switch( item->type)
{
case adminnav_eItemType_ProjHier:
((ItemProjHier *)item)->open_children( adminnav,
event->object.x, event->object.y);
break;
case adminnav_eItemType_Project:
((ItemProject *)item)->open_children( adminnav,
event->object.x, event->object.y);
break;
case adminnav_eItemType_Db:
((ItemDb *)item)->open_children( adminnav,
item->open_children( adminnav,
event->object.x, event->object.y);
break;
default:
;
}
break;
default:
;
......@@ -406,16 +435,16 @@ int AdminNav::get_select( void **item)
return 1;
}
void AdminNav::tree_build()
void AdminNav::proj_tree_build()
{
adminnav_sMenu *menu_p;
adminnav_sProjMenu *menu_p;
brow_SetNodraw( brow->ctx);
tree_load();
proj_tree_load();
// Create the root items
for ( menu_p = menu_tree; menu_p; menu_p = menu_p->next)
for ( menu_p = proj_menu_tree; menu_p; menu_p = menu_p->next)
{
switch( menu_p->item_type)
{
......@@ -438,6 +467,125 @@ void AdminNav::tree_build()
brow_Redraw( brow->ctx, 0);
}
void AdminNav::volumes_tree_build()
{
FILE *fp;
char filename[256]="$pwra_db/pwr_volumelist.dat";
char item_str[5][80];
int nr;
char line[200];
dcli_translate_filename( filename, filename);
if ( !check_file( filename))
return;
fp = fopen( filename, "r");
if ( !fp)
return;
brow_SetNodraw( brow->ctx);
while ( admin_read_line( line, sizeof(line), fp))
{
nr = dcli_parse( line, " ", "", (char *)item_str,
sizeof( item_str) / sizeof( item_str[0]), sizeof( item_str[0]), 0);
if ( nr == 0)
continue;
if ( item_str[0][0] == '!' || item_str[0][0] == '#') {
new ItemVolComment( this, line, 0, flow_eDest_IntoLast);
}
else {
if ( nr < 3) {
printf( "** Syntax error in pwr_volumelist.dat : \"%s\"", line);
continue;
}
new ItemVolume( this, item_str[0], item_str[1], item_str[2],
0, flow_eDest_IntoLast);
}
}
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
fclose( fp);
}
void AdminNav::users_tree_build()
{
char filename[256];
int sts;
gu = new GeUser();
sts = dcli_get_defaultfilename( user_cFilename, filename, "");
gu->load( filename);
brow_SetNodraw( brow->ctx);
SystemList *group = gu->root_system();
while ( group) {
new ItemUsersGroup( this, group, 0, flow_eDest_IntoLast);
group = group->next_system();
}
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
}
int AdminNav::volumes_save()
{
char filename[256]="$pwra_db/pwr_volumelist.dat";
ofstream fp;
brow_tObject *object_list;
int object_cnt;
Item *item;
dcli_translate_filename( filename, filename);
fp.open( filename);
if ( !fp)
return 0;
brow_GetObjectList( brow->ctx, &object_list, &object_cnt);
for ( int i = 0; i < object_cnt; i++) {
brow_GetUserData( object_list[i], (void **)&item);
item->print( fp);
}
fp.close();
return 1;
}
int AdminNav::volumes_add( char *volumename, char *volumeid, char *projectname,
brow_tNode node, flow_eDest dest)
{
pwr_tVolumeId vid;
brow_tObject *object_list;
int object_cnt;
Item *item;
// Check that volid and name are unic
cdh_StringToVolumeId( volumeid, &vid);
brow_GetObjectList( brow->ctx, &object_list, &object_cnt);
for ( int i = 0; i < object_cnt; i++) {
brow_GetUserData( object_list[i], (void **)&item);
switch ( item->type) {
case adminnav_eItemType_Volume: {
ItemVolume *vitem = (ItemVolume *)item;
if ( vitem->vid == vid ||
cdh_NoCaseStrcmp( volumename, vitem->name) == 0)
return 0;
break;
}
default:
;
}
}
new ItemVolume( this, volumename, volumeid, projectname, node, dest);
return 1;
}
void AdminNav::volumes_delete( brow_tNode node)
{
brow_DeleteNode( brow->ctx, node);
}
void AdminNav::refresh()
{
char open_objects[100][80];
......@@ -464,20 +612,7 @@ void AdminNav::refresh()
if ( (open = brow_IsOpen( object_list[i])))
{
brow_GetUserData( object_list[i], (void **)&object_item);
switch( object_item->type)
{
case adminnav_eItemType_ProjHier:
strcpy( open_objects[open_cnt], ((ItemProjHier *)object_item)->hierarchy);
break;
case adminnav_eItemType_Project:
strcpy( open_objects[open_cnt], ((ItemProject *)object_item)->hierarchy);
break;
case adminnav_eItemType_Db:
strcpy( open_objects[open_cnt], ((ItemProject *)object_item)->hierarchy);
break;
default:
;
}
strcpy( open_objects[open_cnt], object_item->identity());
open_type[open_cnt] = open;
open_cnt++;
if ( open_cnt == 100)
......@@ -492,23 +627,7 @@ void AdminNav::refresh()
{
brow_GetUserData( node_list[0], (void **)&item_sel);
sel_type = item_sel->type;
switch( item_sel->type)
{
case adminnav_eItemType_ProjHier:
strcpy( sel_object, ((ItemProjHier *)item_sel)->hierarchy);
break;
case adminnav_eItemType_Project:
strcpy( sel_object, ((ItemProject *)item_sel)->hierarchy);
break;
case adminnav_eItemType_Db:
strcpy( sel_object, ((ItemDb *)item_sel)->hierarchy);
break;
case adminnav_eItemType_Volume:
strcpy( sel_object, ((ItemVolume *)item_sel)->hierarchy);
break;
default:
;
}
strcpy( sel_object, item_sel->identity());
free( node_list);
}
......@@ -516,8 +635,22 @@ void AdminNav::refresh()
brow_DeleteAll( brow->ctx);
// Restore the rootlist
tree_free();
tree_build();
switch( mode) {
case adminnav_eMode_Projects:
proj_tree_free();
proj_tree_build();
break;
case adminnav_eMode_Users:
users_tree_free();
users_tree_build();
break;
case adminnav_eMode_Volumes:
volumes_tree_free();
volumes_tree_build();
break;
default:
;
}
// Open all previously open objects
for ( i = 0; i < open_cnt; i++)
......@@ -527,40 +660,11 @@ void AdminNav::refresh()
for ( j = object_cnt - 1; j >= 0; j--)
{
brow_GetUserData( object_list[j], (void **)&object_item);
switch( object_item->type)
{
case adminnav_eItemType_ProjHier:
if ( strcmp( ((ItemProjHier *)object_item)->hierarchy,
open_objects[i]) == 0)
{
if ( open_type[i] & adminnav_mOpen_Children)
((ItemProjHier *)object_item)->open_children( this, 0, 0);
found = 1;
}
break;
case adminnav_eItemType_Project:
if ( strcmp( ((ItemProject *)object_item)->hierarchy,
open_objects[i]) == 0)
{
if ( open_type[i] & adminnav_mOpen_Children)
((ItemProject *)object_item)->open_children( this, 0, 0);
found = 1;
}
break;
case adminnav_eItemType_Db:
if ( strcmp( ((ItemDb *)object_item)->hierarchy,
open_objects[i]) == 0)
{
if ( open_type[i] & adminnav_mOpen_Children)
((ItemDb *)object_item)->open_children( this, 0, 0);
found = 1;
}
break;
default:
;
}
if ( found)
if ( strcmp( object_item->identity(), open_objects[i]) == 0) {
if ( open_type[i] & adminnav_mOpen_Children)
object_item->open_children( this, 0, 0);
break;
}
}
}
......@@ -573,50 +677,11 @@ void AdminNav::refresh()
brow_GetUserData( object_list[j], (void **)&object_item);
found = 0;
switch( object_item->type)
{
case adminnav_eItemType_ProjHier:
if ( strcmp( ((ItemProjHier *)object_item)->hierarchy,
sel_object) == 0)
{
brow_SetInverse( ((ItemProjHier *)object_item)->node, 1);
brow_SelectInsert( brow->ctx, ((ItemProjHier *)object_item)->node);
found = 1;
}
break;
case adminnav_eItemType_Project:
if ( strcmp( ((ItemProject *)object_item)->hierarchy,
sel_object) == 0)
{
brow_SetInverse( ((ItemProject *)object_item)->node, 1);
brow_SelectInsert( brow->ctx, ((ItemProject *)object_item)->node);
found = 1;
}
break;
case adminnav_eItemType_Db:
if ( strcmp( ((ItemDb *)object_item)->hierarchy,
sel_object) == 0)
{
brow_SetInverse( ((ItemDb *)object_item)->node, 1);
brow_SelectInsert( brow->ctx, ((ItemDb *)object_item)->node);
found = 1;
}
break;
case adminnav_eItemType_Volume:
if ( strcmp( ((ItemVolume *)object_item)->hierarchy,
sel_object) == 0)
{
brow_SetInverse( ((ItemVolume *)object_item)->node, 1);
brow_SelectInsert( brow->ctx, ((ItemVolume *)object_item)->node);
found = 1;
}
break;
default:
;
if ( strcmp( object_item->identity(), sel_object) == 0) {
brow_SetInverse( object_item->get_node(), 1);
brow_SelectInsert( brow->ctx, object_item->get_node());
break;
}
if ( found)
break;
}
}
......@@ -640,7 +705,7 @@ int AdminNav::basename_to_baseroot( char *name, char *root)
return 0;
}
void AdminNav::tree_load()
void AdminNav::proj_tree_load()
{
FILE *fp;
char filename[80]="$pwra_db/pwr_projectlist.dat";
......@@ -649,7 +714,7 @@ void AdminNav::tree_load()
char *s1, *s2, *s;
int len;
char line[200];
adminnav_sMenu *menu_p;
adminnav_sProjMenu *menu_p;
adminnav_sBase *base_p;
dcli_translate_filename( filename, filename);
......@@ -684,7 +749,7 @@ void AdminNav::tree_load()
continue;
}
menu_p = (adminnav_sMenu *) calloc( 1, sizeof(*menu_p));
menu_p = (adminnav_sProjMenu *) calloc( 1, sizeof(*menu_p));
strcpy( menu_p->project, item_str[0]);
menu_p->item_type = adminnav_eItemType_Project;
if ( nr > 1)
......@@ -718,10 +783,10 @@ void AdminNav::tree_load()
fclose(fp);
}
void AdminNav::insert_tree( adminnav_sMenu *menu, adminnav_sMenu *parent,
void AdminNav::insert_tree( adminnav_sProjMenu *menu, adminnav_sProjMenu *parent,
char *hierarchy)
{
adminnav_sMenu *menu_p, *menu_np;
adminnav_sProjMenu *menu_p, *menu_np;
char lhierarchy[80];
char hier[80];
char *s;
......@@ -731,11 +796,11 @@ void AdminNav::insert_tree( adminnav_sMenu *menu, adminnav_sMenu *parent,
(strcmp( hierarchy, "") == 0 || !strchr( hierarchy, '-')))
{
// Insert as toplevel
if ( ! menu_tree)
menu_tree = menu;
if ( ! proj_menu_tree)
proj_menu_tree = menu;
else
{
for ( menu_p = menu_tree; menu_p->next; menu_p = menu_p->next)
for ( menu_p = proj_menu_tree; menu_p->next; menu_p = menu_p->next)
;
menu_p->next = menu;
}
......@@ -760,7 +825,7 @@ void AdminNav::insert_tree( adminnav_sMenu *menu, adminnav_sMenu *parent,
*s = 0;
// Try to find this hierarchy
if ( !parent)
menu_p = menu_tree;
menu_p = proj_menu_tree;
else
menu_p = parent->child_list;
for ( ; menu_p; menu_p = menu_p->next)
......@@ -773,7 +838,7 @@ void AdminNav::insert_tree( adminnav_sMenu *menu, adminnav_sMenu *parent,
}
// Not found, create a hierarchy item, and insert last
menu_np = (adminnav_sMenu *) calloc( 1, sizeof(*menu_np));
menu_np = (adminnav_sProjMenu *) calloc( 1, sizeof(*menu_np));
strcpy( menu_np->name, lhierarchy);
if ( !parent)
strcpy( menu_np->hierarchy, lhierarchy);
......@@ -788,11 +853,11 @@ void AdminNav::insert_tree( adminnav_sMenu *menu, adminnav_sMenu *parent,
if ( !parent)
{
if ( !menu_tree)
menu_tree = menu_np;
if ( !proj_menu_tree)
proj_menu_tree = menu_np;
else
{
for ( menu_p = menu_tree; menu_p->next; menu_p = menu_p->next)
for ( menu_p = proj_menu_tree; menu_p->next; menu_p = menu_p->next)
;
menu_p->next = menu_np;
}
......@@ -812,12 +877,22 @@ void AdminNav::insert_tree( adminnav_sMenu *menu, adminnav_sMenu *parent,
}
}
void AdminNav::tree_free()
void AdminNav::proj_tree_free()
{
menu_tree = 0;
proj_menu_tree = 0;
baselist = 0;
}
void AdminNav::volumes_tree_free()
{
}
void AdminNav::users_tree_free()
{
delete gu;
gu = 0;
}
void AdminNav::enable_events()
{
brow_EnableEvent( brow->ctx, flow_eEvent_MB1Click, flow_eEventType_CallBack,
......@@ -865,7 +940,7 @@ static int adminnav_init_brow_cb( FlowCtx *fctx, void *client_data)
// Create the root item
adminnav->tree_build();
adminnav->proj_tree_build();
return 1;
}
......@@ -885,7 +960,7 @@ static int admin_read_line( char *line, unsigned int maxsize, FILE *file)
}
ItemProjHier::ItemProjHier( AdminNav *adminnav,
char *item_name, char *item_hier, adminnav_sMenu *item_child_list,
char *item_name, char *item_hier, adminnav_sProjMenu *item_child_list,
brow_tNode dest, flow_eDest dest_code) :
Item(adminnav_eItemType_ProjHier), child_list(item_child_list)
{
......@@ -917,7 +992,7 @@ int ItemProjHier::open_children( AdminNav *adminnav, double x, double y)
// Display childlist
double node_x, node_y;
Item *item;
adminnav_sMenu *menu;
adminnav_sProjMenu *menu;
brow_GetNodePosition( node, &node_x, &node_y);
brow_SetNodraw( adminnav->brow->ctx);
......@@ -1007,6 +1082,7 @@ int ItemProject::open_children( AdminNav *adminnav, double x, double y)
FILE *fp;
char line[200];
int i, found;
bool v34 = false;
if ( !brow_IsOpen( node))
action_open = 1;
......@@ -1028,35 +1104,64 @@ int ItemProject::open_children( AdminNav *adminnav, double x, double y)
brow_GetNodePosition( node, &node_x, &node_y);
brow_SetNodraw( adminnav->brow->ctx);
while ( admin_read_line( line, sizeof(line), fp))
{
nr = dcli_parse( line, " ", "", (char *)item_str,
sizeof( item_str) / sizeof( item_str[0]), sizeof( item_str[0]), 0);
if ( nr < 3)
continue;
if ( strncmp( base, "X3.4", 4) == 0 || strncmp( base, "V3.4", 4) == 0)
v34 = true;
// Check that it's not already inserted
found = 0;
for ( i = 0; i < db_cnt; i++)
{
if ( strcmp( dblist[i], item_str[2]) == 0)
{
found = 1;
break;
}
if ( v34) {
while ( admin_read_line( line, sizeof(line), fp)) {
nr = dcli_parse( line, " ", "", (char *)item_str,
sizeof( item_str) / sizeof( item_str[0]), sizeof( item_str[0]), 0);
if ( nr < 3)
continue;
// Check that it's not already inserted
found = 0;
for ( i = 0; i < db_cnt; i++) {
if ( strcmp( dblist[i], item_str[2]) == 0) {
found = 1;
break;
}
}
if ( !found) {
strcpy( dblist[db_cnt], item_str[2]);
db_cnt++;
}
}
if ( !found)
{
strcpy( dblist[db_cnt], item_str[2]);
db_cnt++;
}
else {
while ( admin_read_line( line, sizeof(line), fp)) {
nr = dcli_parse( line, " ", "", (char *)item_str,
sizeof( item_str) / sizeof( item_str[0]), sizeof( item_str[0]), 0);
if ( nr < 4)
continue;
if ( !(cdh_NoCaseStrcmp( item_str[2], "RootVolume") == 0 &&
cdh_NoCaseStrcmp( item_str[3], "cnf") == 0))
continue;
// Check that it's not already inserted
found = 0;
for ( i = 0; i < db_cnt; i++) {
if ( strcmp( dblist[i], item_str[0]) == 0) {
found = 1;
break;
}
}
if ( !found) {
strcpy( dblist[db_cnt], item_str[0]);
db_cnt++;
}
}
}
fclose( fp);
for ( i = 0; i < db_cnt; i++)
{
new ItemDb( adminnav, dblist[i],
if ( v34)
new ItemProjDb( adminnav, dblist[i],
project, dblist[i], root, node, flow_eDest_IntoLast);
else
new ItemProjVolume( adminnav, dblist[i],
project, "", dblist[i], root, node, flow_eDest_IntoLast);
}
if ( db_cnt)
brow_SetOpen( node, adminnav_mOpen_Children);
......@@ -1085,12 +1190,12 @@ int ItemProject::close( AdminNav *adminnav, double x, double y)
return 1;
}
ItemDb::ItemDb( AdminNav *adminnav, char *item_name, char *item_project,
ItemProjDb::ItemProjDb( AdminNav *adminnav, char *item_name, char *item_project,
char *item_db, char *item_root,
brow_tNode dest, flow_eDest dest_code) :
Item( adminnav_eItemType_Db), node(NULL)
Item( adminnav_eItemType_ProjDb), node(NULL)
{
type = adminnav_eItemType_Db;
type = adminnav_eItemType_ProjDb;
strcpy( name, item_name);
strcpy( project, item_project);
strcpy( db, item_db);
......@@ -1106,7 +1211,7 @@ ItemDb::ItemDb( AdminNav *adminnav, char *item_name, char *item_project,
brow_SetAnnotation( node, 0, name, strlen(name));
}
int ItemDb::open_children( AdminNav *adminnav, double x, double y)
int ItemProjDb::open_children( AdminNav *adminnav, double x, double y)
{
int action_open;
char filename[120];
......@@ -1146,7 +1251,7 @@ int ItemDb::open_children( AdminNav *adminnav, double x, double y)
if ( strcmp( db, item_str[2]) == 0)
{
child_cnt++;
new ItemVolume( adminnav, item_str[0],
new ItemProjVolume( adminnav, item_str[0],
project, db, item_str[0], root, node, flow_eDest_IntoLast);
}
}
......@@ -1162,7 +1267,7 @@ int ItemDb::open_children( AdminNav *adminnav, double x, double y)
return 1;
}
int ItemDb::close( AdminNav *adminnav, double x, double y)
int ItemProjDb::close( AdminNav *adminnav, double x, double y)
{
double node_x, node_y;
......@@ -1179,12 +1284,12 @@ int ItemDb::close( AdminNav *adminnav, double x, double y)
return 1;
}
ItemVolume::ItemVolume( AdminNav *adminnav, char *item_name, char *item_project,
ItemProjVolume::ItemProjVolume( AdminNav *adminnav, char *item_name, char *item_project,
char *item_db, char *item_volume, char *item_root,
brow_tNode dest, flow_eDest dest_code) :
Item( adminnav_eItemType_Volume), node(NULL)
Item( adminnav_eItemType_ProjVolume), node(NULL)
{
type = adminnav_eItemType_Volume;
type = adminnav_eItemType_ProjVolume;
strcpy( name, item_name);
strcpy( project, item_project);
strcpy( db, item_db);
......@@ -1200,3 +1305,194 @@ ItemVolume::ItemVolume( AdminNav *adminnav, char *item_name, char *item_project,
// Set object name annotation
brow_SetAnnotation( node, 0, name, strlen(name));
}
ItemVolume::ItemVolume( AdminNav *adminnav, char *item_name, char *item_vid,
char *item_project,
brow_tNode dest, flow_eDest dest_code) :
Item( adminnav_eItemType_Volume), node(NULL)
{
pwr_tStatus sts;
strcpy( name, item_name);
strcpy( project, item_project);
sts = cdh_StringToVolumeId( item_vid, &vid);
brow_CreateNode( adminnav->brow->ctx, name, adminnav->brow->nc_object,
dest, dest_code, (void *)this, 1, &node);
// Set pixmap
brow_SetAnnotPixmap( node, 0, adminnav->brow->pixmap_volume);
// Set object name annotation
brow_SetAnnotation( node, 0, name, strlen(name));
brow_SetAnnotation( node, 1, item_vid, strlen(item_vid));
brow_SetAnnotation( node, 2, project, strlen(project));
}
void ItemVolume::modify( char *item_name, char *item_vid, char *item_project)
{
strcpy( name, item_name);
strcpy( project, item_project);
cdh_StringToVolumeId( item_vid, &vid);
// Set annotations
brow_SetAnnotation( node, 0, name, strlen(name));
brow_SetAnnotation( node, 1, item_vid, strlen(item_vid));
brow_SetAnnotation( node, 2, project, strlen(project));
}
void ItemVolume::print( ofstream& fp)
{
char volumeid[80];
strcpy( volumeid, cdh_VolumeIdToString( NULL, vid, 0, 0));
fp << " " << name;
for ( int i = 0; i < (int)(15 - strlen(name)); i++)
fp << " ";
fp << " ";
fp << volumeid;
for ( int i = 0; i < (int)(15 - strlen(volumeid)); i++)
fp << " ";
fp << " ";
fp << project << endl;
}
ItemVolComment::ItemVolComment( AdminNav *adminnav, char *item_text,
brow_tNode dest, flow_eDest dest_code) :
Item( adminnav_eItemType_VolComment), node(NULL)
{
strncpy( text, item_text, sizeof(text));
text[sizeof(text)-1] = 0;
brow_CreateNode( adminnav->brow->ctx, "Comment", adminnav->brow->nc_object,
dest, dest_code, (void *)this, 1, &node);
// Set pixmap
// brow_SetAnnotPixmap( node, 0, adminnav->brow->pixmap_volume);
// Set object name annotation
if ( strlen( item_text) > 1)
brow_SetAnnotation( node, 0, &item_text[1], strlen(item_text) - 1);
}
void ItemVolComment::print( ofstream& fp)
{
char text[200];
brow_GetAnnotation( node, 0, text, sizeof(text));
fp << "!" << text << endl;
}
ItemUsersGroup::ItemUsersGroup( AdminNav *adminnav, SystemList *item_group,
brow_tNode dest, flow_eDest dest_code) :
Item( adminnav_eItemType_UsersGroup), node(NULL), group(item_group)
{
adminnav->gu->get_system_name( group, name);
brow_CreateNode( adminnav->brow->ctx, "Group", adminnav->brow->nc_object,
dest, dest_code, (void *)this, 1, &node);
// Set pixmap
if ( group->first_system() || group->first_user())
brow_SetAnnotPixmap( node, 0, adminnav->brow->pixmap_map);
else
brow_SetAnnotPixmap( node, 0, adminnav->brow->pixmap_leaf);
// Set object name annotation
brow_SetAnnotation( node, 0, group->get_name(), strlen(group->get_name()));
brow_SetAnnotation( node, 1, "SystemGroup", strlen("SystemGroup"));
}
int ItemUsersGroup::open_children( AdminNav *adminnav, double x, double y)
{
int action_open;
int child_cnt = 0;
if ( !brow_IsOpen( node))
action_open = 1;
else
action_open = 0;
if ( action_open)
{
// Display childlist
double node_x, node_y;
brow_GetNodePosition( node, &node_x, &node_y);
brow_SetNodraw( adminnav->brow->ctx);
UserList *user = group->first_user();
while ( user) {
new ItemUser( adminnav, user, node, flow_eDest_IntoLast);
user = user->next_user();
child_cnt++;
}
SystemList *child = group->first_system();
while ( child) {
new ItemUsersGroup( adminnav, child, node, flow_eDest_IntoLast);
child = child->next_system();
child_cnt++;
}
if ( child_cnt)
brow_SetOpen( node, adminnav_mOpen_Children);
brow_ResetNodraw( adminnav->brow->ctx);
brow_Redraw( adminnav->brow->ctx, node_y);
}
else
close( adminnav, x, y);
return 1;
}
int ItemUsersGroup::close( AdminNav *adminnav, double x, double y)
{
double node_x, node_y;
if ( brow_IsOpen( node))
{
// Close
brow_GetNodePosition( node, &node_x, &node_y);
brow_SetNodraw( adminnav->brow->ctx);
brow_CloseNode( adminnav->brow->ctx, node);
brow_ResetOpen( node, adminnav_mOpen_All);
brow_ResetNodraw( adminnav->brow->ctx);
brow_Redraw( adminnav->brow->ctx, node_y);
}
return 1;
}
ItemUser::ItemUser( AdminNav *adminnav, UserList *item_user,
brow_tNode dest, flow_eDest dest_code) :
Item( adminnav_eItemType_User), node(NULL), user(item_user)
{
SystemList *group = adminnav->gu->get_system( user);
adminnav->gu->get_system_name( group, name);
strcat( name, "-");
strcat( name, user->get_name());
brow_CreateNode( adminnav->brow->ctx, "User", adminnav->brow->nc_object,
dest, dest_code, (void *)this, 1, &node);
// Set pixmap
brow_SetAnnotPixmap( node, 0, adminnav->brow->pixmap_symbol);
// Set object name annotation
brow_SetAnnotation( node, 0, user->get_name(), strlen(user->get_name()));
brow_SetAnnotation( node, 1, "User", strlen("User"));
}
......@@ -8,6 +8,8 @@
<Description>. */
#include <iostream.h>
#if defined __cplusplus
extern "C" {
#endif
......@@ -15,6 +17,11 @@ extern "C" {
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef co_user_h
# include "co_user.h"
#endif
#ifndef flow_h
#include "flow.h"
#endif
......@@ -29,7 +36,14 @@ extern "C" {
#define adminnav_cVersion "X3.0b"
typedef struct adminnav_s_Menu {
typedef enum {
adminnav_eMode_Projects,
adminnav_eMode_Volumes,
adminnav_eMode_Users
} adminnav_eMode;
typedef struct adminnav_s_ProjMenu {
char name[80];
int item_type;
char project[120];
......@@ -38,10 +52,10 @@ typedef struct adminnav_s_Menu {
char hierarchy[120];
char description[120];
int pixmap;
struct adminnav_s_Menu *child_list;
struct adminnav_s_Menu *parent;
struct adminnav_s_Menu *next;
} adminnav_sMenu;
struct adminnav_s_ProjMenu *child_list;
struct adminnav_s_ProjMenu *parent;
struct adminnav_s_ProjMenu *next;
} adminnav_sProjMenu;
typedef struct adminnav_s_Base {
char name[80];
......@@ -52,8 +66,12 @@ typedef struct adminnav_s_Base {
typedef enum {
adminnav_eItemType_ProjHier,
adminnav_eItemType_Project,
adminnav_eItemType_Db,
adminnav_eItemType_Volume
adminnav_eItemType_ProjDb,
adminnav_eItemType_ProjVolume,
adminnav_eItemType_Volume,
adminnav_eItemType_VolComment,
adminnav_eItemType_User,
adminnav_eItemType_UsersGroup
} adminnav_eItemType;
typedef enum {
......@@ -84,16 +102,27 @@ class AdminNav {
int trace_started;
void (*message_cb)( void *, char, char *);
int (*set_focus_cb)( void *, void *);
adminnav_sMenu *menu_tree;
adminnav_sProjMenu *proj_menu_tree;
adminnav_sBase *baselist;
int displayed;
adminnav_eMode mode;
GeUser *gu;
void message( char sev, char *text);
void tree_build();
void tree_load();
void tree_free();
void proj_tree_build();
void proj_tree_load();
void proj_tree_free();
void volumes_tree_build();
void volumes_tree_free();
void users_tree_build();
void users_tree_free();
int volumes_save();
int volumes_add( char *volumename, char *volumeid, char *projectname,
brow_tNode node, flow_eDest dest);
void volumes_delete( brow_tNode node);
void set_inputfocus( int focus);
void insert_tree( adminnav_sMenu *menu, adminnav_sMenu *parent, char *hierarchy);
void insert_tree( adminnav_sProjMenu *menu, adminnav_sProjMenu *parent,
char *hierarchy);
void enable_events();
int get_select( void **item);
int basename_to_baseroot( char *name, char *root);
......@@ -102,6 +131,7 @@ class AdminNav {
void zoom( double zoom_factor);
void get_zoom( double *zoom_factor);
void unzoom();
void view( adminnav_eMode m);
};
......@@ -110,20 +140,29 @@ class Item {
Item( adminnav_eItemType item_type) :
type( item_type) {};
adminnav_eItemType type;
virtual int open_children( AdminNav *adminnav, double x, double y)
{ return 0;}
virtual int close( AdminNav *adminnav, double x, double y)
{ return 0;}
virtual char *identity() { return "";}
virtual brow_tNode get_node() = 0;
virtual void print( ofstream& fp) {}
};
class ItemProjHier : public Item {
public:
ItemProjHier( AdminNav *adminnav, char *item_name, char *item_hier,
adminnav_sMenu *item_child_list,
adminnav_sProjMenu *item_child_list,
brow_tNode dest, flow_eDest dest_code);
brow_tNode node;
char name[120];
char hierarchy[120];
adminnav_sMenu *child_list;
adminnav_sProjMenu *child_list;
int open_children( AdminNav *adminnav, double x, double y);
int close( AdminNav *adminnav, double x, double y);
char *identity() { return hierarchy;}
brow_tNode get_node() { return node;}
};
class ItemProject : public Item {
......@@ -141,11 +180,13 @@ class ItemProject : public Item {
char description[120];
int open_children( AdminNav *adminnav, double x, double y);
int close( AdminNav *adminnav, double x, double y);
char *identity() { return hierarchy;}
brow_tNode get_node() { return node;}
};
class ItemDb : public Item {
class ItemProjDb : public Item {
public:
ItemDb( AdminNav *adminnav, char *item_name,
ItemProjDb( AdminNav *adminnav, char *item_name,
char *item_project, char *item_db, char *item_root,
brow_tNode dest, flow_eDest dest_code);
brow_tNode node;
......@@ -156,11 +197,13 @@ class ItemDb : public Item {
char root[120];
int open_children( AdminNav *adminnav, double x, double y);
int close( AdminNav *adminnav, double x, double y);
char *identity() { return hierarchy;}
brow_tNode get_node() { return node;}
};
class ItemVolume : public Item {
class ItemProjVolume : public Item {
public:
ItemVolume( AdminNav *adminnav, char *item_name,
ItemProjVolume( AdminNav *adminnav, char *item_name,
char *item_project, char *item_db, char *item_volume, char *item_root,
brow_tNode dest, flow_eDest dest_code);
brow_tNode node;
......@@ -170,9 +213,84 @@ class ItemVolume : public Item {
char hierarchy[120];
char volume[120];
char root[120];
char *identity() { return hierarchy;}
brow_tNode get_node() { return node;}
};
class ItemVolume : public Item {
public:
ItemVolume( AdminNav *adminnav,
char *item_name, char *item_vid, char *item_project,
brow_tNode dest, flow_eDest dest_code);
brow_tNode node;
pwr_tVolumeId vid;
char name[120];
char project[120];
char *identity() { return name;}
brow_tNode get_node() { return node;}
void modify( char *item_name, char *item_vid, char *item_project);
void print( ofstream& fp);
};
class ItemVolComment : public Item {
public:
ItemVolComment( AdminNav *adminnav,
char *item_text,
brow_tNode dest, flow_eDest dest_code);
brow_tNode node;
char text[120];
char *identity() { return text;}
brow_tNode get_node() { return node;}
void print( ofstream& fp);
};
class ItemUsersGroup : public Item {
public:
ItemUsersGroup( AdminNav *adminnav,
SystemList *item_group,
brow_tNode dest, flow_eDest dest_code);
brow_tNode node;
SystemList *group;
char name[120];
int open_children( AdminNav *adminnav, double x, double y);
int close( AdminNav *adminnav, double x, double y);
char *identity() { return name;}
brow_tNode get_node() { return node;}
};
class ItemUser : public Item {
public:
ItemUser( AdminNav *adminnav,
UserList *item_user,
brow_tNode dest, flow_eDest dest_code);
brow_tNode node;
UserList *user;
char name[120];
char *identity() { return name;}
brow_tNode get_node() { return node;}
};
#if defined __cplusplus
}
#endif
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment