Commit 6c337b1c authored by claes's avatar claes

More work on project list as extern volume

parent 3b0a1fb7
#! /bin/bash
#
# Proview $Id: pwrp_env.sh,v 1.8 2005-09-01 14:57:49 claes Exp $
# Proview $Id: pwrp_env.sh,v 1.9 2005-10-25 12:05:37 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
......@@ -50,6 +50,7 @@ declare -i pwrc__projnameinv=26
declare -i pwrc__mysqldbcopy=27
declare -i pwrc__mysqldbrena=28
declare -i pwrc__mysql=29
declare -i pwrc__noroot=30
pwrc_get_variables()
......
#! /bin/bash
#!/bin/bash
#
# Proview $Id: wb_admin.sh,v 1.4 2005-09-01 14:57:49 claes Exp $
# Proview $Id: wb_admin.sh,v 1.5 2005-10-25 12:05:37 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
......@@ -42,7 +42,7 @@ echo "args: $1 $2 $3 $4 $5"
source pwrp_env.sh setdb $database
fi
wb "$username" "$password" $volume &
wb -q "$username" "$password" $volume &
}
wb_adm_create_func ()
......
#
# Proview $Id: wb_open_db.sh,v 1.3 2005-09-01 14:57:49 claes Exp $
# Proview $Id: wb_open_db.sh,v 1.4 2005-10-25 12:05:37 claes Exp $
# Copyright (C) 2005 SSAB Oxelösund AB.
#
# This program is free software; you can redistribute it and/or
......@@ -33,4 +33,4 @@ if [ -z $database ]; then
fi
echo "-- Opening volume '$database'"
wb $username $password $database
wb -q $username $password $database
#!/bin/bash
#
# Proview $Id: wb_pvd_pl.sh,v 1.1 2005-10-25 12:05:37 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# 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 the program, if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
set -o xtrace
declare -ix pwrc_status=$pwrc__success
declare -i pwrc__success=0
declare -i pwrc__dbnotfound=1
declare -i pwrc__noproj=3
declare -i pwrc__rootexist=4
declare -i pwrc__notconfigured=5
declare -i pwrc__projlistfile=6
declare -i pwrc__projalrexist=7
declare -i pwrc__basealrexist=8
declare -i pwrc__nobase=9
declare -i pwrc__projlistfileacc=10
declare -i pwrc__syntax=11
declare -i pwrc__rootacc=12
declare -i pwrc__rootcreate=13
declare -i pwrc__rootdelete=14
declare -i pwrc__dbdelete=15
declare -i pwrc__baseexist=16
declare -i pwrc__move=17
declare -i pwrc__notmysqlsrv=18
declare -i pwrc__datadir=19
declare -i pwrc__nodb=20
declare -i pwrc__notemplatedb=21
declare -i pwrc__dbalrexist=22
declare -i pwrc__copy=23
declare -i pwrc__dbcreate=24
declare -i pwrc__projnotset=25
declare -i pwrc__projnameinv=26
declare -i pwrc__mysqldbcopy=27
declare -i pwrc__mysqldbrena=28
declare -i pwrc__mysql=29
declare -i pwrc__noroot=30
wb_pl_opendb_func ()
{
#
# Command is "opendb"
#
# Arguments 1: project
# 2: username
# 3: password
# 4: database
# 5: volume
local project=$1
local username=$2
local password=$3
local database=$4
local volume=$5
echo "args: $1 $2 $3 $4 $5"
source pwrp_env.sh set project $project
if [ "$database" != "dbdirectory" ]; then
source pwrp_env.sh setdb $database
fi
wb -q "$username" "$password" $volume &
}
wb_pl_check_func ()
{
cmd="move"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "check move"
#
# Arguments 2: source root
# 3: destination root
local srcroot=$2
local destroot=$3
local destdir=${destroot%/*}
if [ ! -e "$srcroot" ]; then
echo "Source root not found"
pwrc_status=$pwrc_noroot
fi
if [ -e "$destroot" ]; then
if [ ! -w "$destroot" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
else
if [ -e "$destroot/common" ]; then
echo "Error: destination root already exist"
pwrc_status=$pwrc__rootexist
return
fi
fi
else
if [ ! -e "$destdir" ]; then
echo "Can't create destination root"
pwrc_status=$pwrc__rootcreate
return
else
if [ ! -w "$destdir" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
fi
fi
fi
pwrc_status=$pwrc__success
return
fi
cmd="create"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "check move"
#
# Arguments 2: destination root
local destroot=$2
local destdir=${destroot%/*}
if [ -e "$destroot" ]; then
if [ ! -w "$destroot" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
else
if [ -e "$destroot/common" ]; then
echo "Error: destination root already exist"
pwrc_status=$pwrc__rootexist
return
fi
fi
else
if [ ! -e "$destdir" ]; then
echo "Can't create destination root"
pwrc_status=$pwrc__rootcreate
return
else
if [ ! -w "$destdir" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
fi
fi
fi
pwrc_status=$pwrc__success
return
fi
}
wb_pl_create_func ()
{
local cmd
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "create project"
#
# Arguments 2: project name
# 3: base name
# 4: project root
# 5: project hierarchy
# 6-: description
pname=$2
bname=$3
proot=$4
source pwrp_env.sh create $@
if [ $pwrc_status -ne 0 ]; then
return $pwrc_status
fi
#source pwrp_env.sh set project $pname
#if [ $pwrc_status -ne 0 ]; then
# return $pwrc_status
#fi
#wb_cmd create volume/name=\"directory\"/ident=254.254.254.253/class=\$DirectoryVolume
fi
}
wb_pl_parse ()
{
local cmd
cmd="opendb"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_pl_opendb_func $1 $2 $3 $4 $5
return
fi
cmd="create"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_pl_create_func $@
return
fi
cmd="check"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_pl_check_func $@
return $pwrc_status
fi
echo "Unknown command"
}
#set -o xtrace
wb_pl_parse $@
#set +o xtrace
#
# Proview $Id: wb_start.sh,v 1.3 2005-09-01 14:57:49 claes Exp $
# Proview $Id: wb_start.sh,v 1.4 2005-10-25 12:05:37 claes Exp $
# Copyright (C) 2005 SSAB Oxelösund AB.
#
# This program is free software; you can redistribute it and/or
......@@ -25,3 +25,8 @@ password=$2
volume=$3
wb $username $password $volume
/*
* Proview $Id: wb.h,v 1.8 2005-09-06 10:43:30 claes Exp $
* Proview $Id: wb.h,v 1.9 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -33,7 +33,8 @@ typedef enum {
wb_eType_Directory,
wb_eType_Class,
wb_eType_Buffer,
wb_eType_ClassEditor
wb_eType_ClassEditor,
wb_eType_ExternVolume
} wb_eType;
typedef enum {
......
/*
* Proview $Id: wb_c_projectreg.c,v 1.1 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
/* wb_c_projectref.c -- work bench methods of the ProjectReg class. */
#include <X11/Intrinsic.h>
#undef Status
#include "co_dcli.h"
#include "wb_pwrs.h"
#include "pwr_baseclasses.h"
#include "wb_ldh_msg.h"
#include "wb_ldh.h"
#include "wb_pwrb_msg.h"
#include "wb_login.h"
/*----------------------------------------------------------------------------*\
To open a PLC program with the PLC editor.
\*----------------------------------------------------------------------------*/
static pwr_tStatus OpenProject (
ldh_sMenuCall *ip
)
{
char *project;
pwr_tStatus sts;
int size;
pwr_tFileName fname;
pwr_tCmd cmd;
sts = ldh_GetObjectPar( ip->PointedSession, ip->Pointed.Objid, "RtBody",
"Project", &project, &size);
if ( EVEN(sts)) return sts;
printf( "Open %s\n", project);
dcli_translate_filename( fname, "$pwr_exe/wb_pvd_pl.sh");
sprintf( cmd,
"%s opendb \"%s\" \"%s\" \"%s\" &",
fname, project, login_prv.username, login_prv.password);
free( project);
sts = system( cmd);
if ( sts == -1 || sts == 127) {
printf("-- Error when creating process.\n");
return sts;
}
return 1;
}
static pwr_tStatus CopyProject (
ldh_sMenuCall *ip
)
{
pwr_tStatus sts;
int size;
pwr_tObjName oname;
pwr_tCid cid;
pwr_tOid oid;
pwr_sClass_ProjectReg *body;
char description[120];
sts = ldh_ObjidToName( ip->PointedSession, ip->Pointed.Objid, ldh_eName_Object,
oname, sizeof(oname), &size);
if ( EVEN(sts)) return sts;
sts = ldh_GetObjectClass( ip->PointedSession, ip->Pointed.Objid, &cid);
if ( EVEN(sts)) return sts;
sts = ldh_GetObjectBody( ip->PointedSession, ip->Pointed.Objid, "RtBody",
(void **)&body, &size);
if ( EVEN(sts)) return sts;
strcat( oname, "2");
strcat( body->Path, "2");
sprintf( description, "%s (Copy of %s)", body->Description, body->Project);
description[79] = 0;
strcpy( body->Description, description);
strcpy( body->CopyFrom, body->Project);
strcat( body->Project, "2");
sts = ldh_CreateObject( ip->PointedSession, &oid, oname, cid,
ip->Pointed.Objid, ldh_eDest_After);
if ( EVEN(sts)) return sts;
sts = ldh_SetObjectBody( ip->PointedSession, oid, "RtBody",
(char *)body, sizeof( *body));
if ( EVEN(sts)) return sts;
free(body);
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindMethods(ProjectReg) = {
pwr_BindMethod(OpenProject),
pwr_BindMethod(CopyProject),
pwr_NullMethod
};
/*
* Proview $Id: wb_i_base_methods.c,v 1.6 2005-09-06 10:43:31 claes Exp $
* Proview $Id: wb_i_base_methods.c,v 1.7 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -36,7 +36,7 @@ pwr_dImport pwr_BindMethods(DsHist);
pwr_dImport pwr_BindMethods(DsTrend);
pwr_dImport pwr_BindMethods(DSup);
pwr_dImport pwr_BindMethods(PlcPgm);
pwr_dImport pwr_BindMethods(DbConfig);
pwr_dImport pwr_BindMethods(ProjectReg);
pwr_dImport pwr_BindMethods(RootVolumeConfig);
pwr_dImport pwr_BindMethods(SubVolumeConfig);
pwr_dImport pwr_BindMethods(SharedVolumeConfig);
......@@ -83,7 +83,7 @@ pwr_dExport pwr_BindClasses(Base) = {
pwr_BindClass(DsTrend),
pwr_BindClass(DSup),
pwr_BindClass(PlcPgm),
pwr_BindClass(DbConfig),
pwr_BindClass(ProjectReg),
pwr_BindClass(RootVolumeConfig),
pwr_BindClass(SubVolumeConfig),
pwr_BindClass(SharedVolumeConfig),
......
/*
* Proview $Id: wb_pvd_file.cpp,v 1.1 2005-09-20 13:14:28 claes Exp $
* Proview $Id: wb_pvd_file.cpp,v 1.2 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -168,9 +168,10 @@ void wb_pvd_file::createObject( wb_procom *pcom, pwr_tOix destoix, int desttype,
}
}
switch (cid) {
case pwr_eClass_PlantHier:
item.body_size = sizeof(pwr_sPlantHier);
case pwr_eClass_Hier:
item.body_size = sizeof(pwr_sHier);
item.body = calloc( 1, item.body_size);
break;
case pwr_cClass_VolumeReg:
......@@ -185,11 +186,20 @@ void wb_pvd_file::createObject( wb_procom *pcom, pwr_tOix destoix, int desttype,
item.body_size = sizeof( pwr_sClass_UserReg);
item.body = calloc( 1, item.body_size);
break;
case pwr_cClass_ProjectReg:
item.body_size = sizeof( pwr_sClass_ProjectReg);
item.body = calloc( 1, item.body_size);
break;
case pwr_cClass_BaseReg:
item.body_size = sizeof( pwr_sClass_BaseReg);
item.body = calloc( 1, item.body_size);
break;
}
if ( strcmp( name, "") == 0)
sprintf( item.name, "O%d", item.oix);
else
strcpy( item.name, name);
item.flags |= pitem_mFlags_Created;
m_list.push_back(item);
pcom->provideObject( 1, item.oix, item.fthoix, item.bwsoix, item.fwsoix,
......@@ -442,5 +452,19 @@ char *wb_pvd_file::longname( pwr_tOix oix)
return m_list[oix].lname;
}
bool wb_pvd_file::find( pwr_tOix fthoix, char *name, pwr_tOix *oix)
{
for ( int i = 0; i < (int) m_list.size(); i++) {
if ( !m_list[i].flags & pitem_mFlags_Deleted) {
if ( m_list[i].fthoix == fthoix &&
cdh_NoCaseStrcmp( name, m_list[i].name) == 0) {
*oix = m_list[i].oix;
return true;
}
}
}
return false;
}
/*
* Proview $Id: wb_pvd_file.h,v 1.1 2005-09-20 13:14:28 claes Exp $
* Proview $Id: wb_pvd_file.h,v 1.2 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -24,7 +24,7 @@
typedef enum {
pitem_mFlags_Deleted = 1 << 0,
pitem_mFlags_Created = 1 << 1,
pitem_mFlags_Created = 1 << 1
} pitem_mFlags;
class pitem {
......@@ -41,24 +41,32 @@ public:
unsigned long flags;
void *body;
unsigned int body_size;
void *userdata;
unsigned int userdata_size;
pitem() : fthoix(0), bwsoix(0), fwsoix(0), fchoix(0), lchoix(0), flags(0),
body(0), body_size(0)
body(0), body_size(0), userdata(0), userdata_size(0)
{ strcpy(lname,"");}
~pitem()
{
if ( body)
free(body);
if ( userdata)
free(userdata);
}
pitem( const pitem& x)
{
memcpy( this, &x, sizeof(pitem));
if ( x.body) {
body = calloc( 1, body_size);
body = malloc( body_size);
memcpy( body, x.body, body_size);
}
if ( x.userdata) {
userdata = malloc( userdata_size);
memcpy( userdata, x.userdata, userdata_size);
}
}
pitem& operator=(const pitem& x)
{
......@@ -67,6 +75,10 @@ public:
body = calloc( 1, body_size);
memcpy( body, x.body, body_size);
}
if ( userdata) {
userdata = calloc( 1, userdata_size);
memcpy( userdata, x.userdata, userdata_size);
}
return *this;
}
};
......@@ -97,6 +109,8 @@ public:
virtual void save( pwr_tStatus *sts) {}
virtual void load( pwr_tStatus *sts) {}
virtual bool find( pwr_tOix fthoix, char *name, pwr_tOix *oix);
vector<pitem> m_list;
pwr_tOix root;
......
/*
* Proview $Id: wb_pvd_gvl.cpp,v 1.1 2005-09-20 13:14:28 claes Exp $
* Proview $Id: wb_pvd_gvl.cpp,v 1.2 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -57,8 +57,8 @@ void wb_pvd_gvl::save( pwr_tStatus *sts)
void wb_pvd_gvl::save_item( pwr_tOix oix, ofstream& of)
{
switch ( m_list[oix].cid) {
case pwr_eClass_PlantHier: {
pwr_sPlantHier *body = (pwr_sPlantHier *)m_list[oix].body;
case pwr_eClass_Hier: {
pwr_sHier *body = (pwr_sHier *)m_list[oix].body;
of << "!**Menu " << m_list[oix].name << " { // " << body->Description << endl;
for ( int ix = m_list[oix].fchoix; ix; ix = m_list[ix].fwsoix)
......@@ -106,7 +106,7 @@ void wb_pvd_gvl::load( pwr_tStatus *rsts)
// Create Root object
pitem rootitem;
strcpy( rootitem.name, "GlobalVolumeList");
rootitem.cid = pwr_eClass_PlantHier;
rootitem.cid = pwr_eClass_Hier;
rootitem.oix = 0;
m_list.push_back(rootitem);
menu_stack[menu_cnt] = rootitem.oix;
......@@ -117,7 +117,7 @@ void wb_pvd_gvl::load( pwr_tStatus *rsts)
line_cnt++;
if ( line[0] == '!') {
if ( strncmp( line, "!**Menu", 7) == 0) {
// Add PlantHier
// Add Hier
char *s = strstr( line, "// ");
if ( s) {
strncpy( description, s+3, sizeof(description));
......@@ -136,13 +136,13 @@ void wb_pvd_gvl::load( pwr_tStatus *rsts)
pitem plantitem;
strcpy( plantitem.name, line_item[1]);
plantitem.cid = pwr_eClass_PlantHier;
plantitem.cid = pwr_eClass_Hier;
plantitem.oix = next_oix++;
plantitem.fthoix = menu_stack[menu_cnt - 1];
plantitem.bwsoix = m_list[plantitem.fthoix].lchoix;
plantitem.fwsoix = 0;
plantitem.body_size = sizeof(pwr_sPlantHier);
pwr_sPlantHier *plantbody = (pwr_sPlantHier *) calloc( 1, plantitem.body_size);
plantitem.body_size = sizeof(pwr_sHier);
pwr_sHier *plantbody = (pwr_sHier *) calloc( 1, plantitem.body_size);
plantitem.body = plantbody;
strcpy( plantbody->Description, description);
......
This diff is collapsed.
/*
* Proview $Id: wb_pvd_pl.h,v 1.1 2005-09-20 13:14:28 claes Exp $
* Proview $Id: wb_pvd_pl.h,v 1.2 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -24,7 +24,8 @@
typedef enum {
pl_mFlags_ProjectModified = 1 << 16,
pl_mFlags_PathModified = 1 << 17
pl_mFlags_PathModified = 1 << 17,
pl_mFlags_Disabled = 1 << 18
} pl_mFlags;
class wb_pvd_pl : public wb_pvd_file {
......@@ -36,12 +37,18 @@ public:
}
void writeAttribute( wb_procom *pcom, pwr_tOix oix, unsigned int offset,
unsigned int size, char *buffer);
void createObject( wb_procom *pcom, pwr_tOix destoix, int desttype,
pwr_tCid cid, char *name);
void load( pwr_tStatus *sts);
void save( pwr_tStatus *sts);
bool check_list( pwr_tStatus *sts);
void process_list( pwr_tStatus *sts);
void save_list( pwr_tStatus *sts);
void save_item( pwr_tOix oix, ofstream &of);
char *basename( char *version);
bool create_hier( char *hier, pwr_tOix *oix);
static void confirm_actions_ok( void *ctx, void *data);
};
#endif
......
/*
* Proview $Id: wb_vrepext.h,v 1.5 2005-09-20 13:14:28 claes Exp $
* Proview $Id: wb_vrepext.h,v 1.6 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -49,6 +49,8 @@ class ext_object
m_flags.m = 0;
m_oid.oix = 0;
m_oid.vid = 0;
time.tv_sec = 0;
time.tv_nsec = 0;
}
ext_object( vext_sAMsgObject *msg, pwr_tVid vid, wb_cdef &cdef) :
rbody_size(0), dbody_size(0), rbody(0), dbody(0)
......@@ -69,6 +71,8 @@ class ext_object
lchoid.vid = vid;
m_cid = msg->cid;
m_flags = cdef.flags();
time.tv_sec = 0;
time.tv_nsec = 0;
}
~ext_object() {
if ( rbody_size) free( rbody);
......
/*
* Proview $Id: wb_wnav.cpp,v 1.25 2005-10-18 05:14:05 claes Exp $
* Proview $Id: wb_wnav.cpp,v 1.26 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1092,7 +1092,7 @@ int WNav::get_select( pwr_sAttrRef **attrref, int **is_attr, int *cnt)
sts = ldh_NameToAttrRef( ldhses, attr_str, ap);
if ( EVEN(sts)) {
// ldh_NameToAttrRef doesn't handle objects with no RtBody...
ap->Objid = item->objid;
*ap = cdh_ObjidToAref( item->objid);
}
*is_attr_p = 0;
}
......@@ -3465,14 +3465,15 @@ static int wnav_init_brow_base_cb( FlowCtx *fctx, void *client_data)
wnav_trace_scan( wnav);
// Execute the init file
strcpy( cmd, "@");
dcli_translate_filename( &cmd[1], wnav_cInitFile);
((WNav *)wnav)->command( cmd);
// Execute the symbolfile
if ( wnav->window_type == wnav_eWindowType_W1)
wnav->gbl.symbolfile_exec( wnav);
if ( wnav->script_filename_cb) {
strcpy( cmd, "@");
strcat( cmd, (wnav->script_filename_cb)( wnav->parent_ctx));
((WNav *)wnav)->command( cmd);
// Execute the symbolfile
if ( wnav->window_type == wnav_eWindowType_W1)
wnav->gbl.symbolfile_exec( wnav);
}
return 1;
}
......
/*
* Proview $Id: wb_wnav.h,v 1.11 2005-09-06 10:43:32 claes Exp $
* Proview $Id: wb_wnav.h,v 1.12 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -69,7 +69,7 @@ extern "C" {
#define wnav_cVersion "X3.3a"
#define wnav_cScriptDescKey "!** Description"
#define wnav_cScriptInvisKey "!** Invisible"
#define wnav_cInitFile "pwrp_login:wtt_init.pwr_com"
#define wnav_cInitFile "pwrp_login:wtt_init"
#define wnav_cSymbolFile "pwrp_login:wtt_symbols.pwr_com"
#define WNAV_BROW_MAX 25
......@@ -247,6 +247,7 @@ class WNav {
void (*create_popup_menu_cb)( void *, pwr_sAttrRef, int, int);
void (*save_cb)( void *);
void (*revert_cb)( void *, int confirm);
char *(*script_filename_cb)( void *);
pwr_tBoolean (*format_selection_cb)( void *, pwr_sAttrRef, XtPointer *,
unsigned long *, pwr_tBoolean, pwr_tBoolean, wnav_eSelectionFormat);
int (*get_global_select_cb)( void *, pwr_sAttrRef **,
......
/*
* Proview $Id: wb_wnav_command.cpp,v 1.32 2005-10-21 16:11:23 claes Exp $
* Proview $Id: wb_wnav_command.cpp,v 1.33 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -326,7 +326,7 @@ dcli_tCmdTable wnav_command_table[] = {
{
"LOGIN",
&wnav_login_func,
{ "dcli_arg1", "dcli_arg2", ""}
{ "dcli_arg1", "dcli_arg2", "/ADMINISTRATOR", ""}
},
{
"TWO",
......@@ -774,14 +774,53 @@ static int wnav_login_func( void *client_data,
char systemgroup[80];
unsigned int priv;
char msg[80];
int administrator;
if ( EVEN( dcli_get_qualifier( "dcli_arg1", arg1_str, sizeof(arg1_str))))
{
administrator = ODD(dcli_get_qualifier( "/ADMINISTRATOR", 0, 0));
if ( administrator) {
sts = user_CheckSystemGroup( "administrator");
if ( EVEN(sts)) {
// Username and password are not required
strcpy( wnav->user, "Administrator");
wnav->priv = pwr_mPrv_Administrator;
strcpy( login_prv.username, "Administrator");
login_prv.priv = (pwr_mPrv) wnav->priv;
wnav->message('I', "Administrator logged in");
return WNAV__SUCCESS;
}
else {
// Check user and password in systemgroup "aministrator"
if ( EVEN( dcli_get_qualifier( "dcli_arg1", arg1_str, sizeof(arg1_str)))) {
wnav->message('E',"Username and password required");
return WNAV__SYNTAX;
}
if ( EVEN( dcli_get_qualifier( "dcli_arg2", arg2_str, sizeof(arg2_str)))) {
wnav->message('E',"Password required");
return WNAV__SYNTAX;
}
cdh_ToLower( arg1_str, arg1_str);
cdh_ToLower( arg2_str, arg2_str);
sts = user_CheckUser( "administrator", arg1_str, arg2_str, &priv);
if ( EVEN(sts))
wnav->message('E',"Login failure");
else {
strcpy( wnav->user, arg1_str);
wnav->priv = pwr_mPrv_Administrator;
strcpy( login_prv.username, arg1_str);
login_prv.priv = (pwr_mPrv) wnav->priv;
sprintf( msg, "User %s logged in", arg1_str);
wnav->message('I', msg);
}
return WNAV__SUCCESS;
}
}
if ( EVEN( dcli_get_qualifier( "dcli_arg1", arg1_str, sizeof(arg1_str)))) {
wnav->message('E',"Syntax error");
return WNAV__SYNTAX;
}
if ( EVEN( dcli_get_qualifier( "dcli_arg2", arg2_str, sizeof(arg2_str))))
{
if ( EVEN( dcli_get_qualifier( "dcli_arg2", arg2_str, sizeof(arg2_str)))) {
wnav->message('E',"Syntax error");
return WNAV__SYNTAX;
}
......
/*
* Proview $Id: wb_wtt.cpp,v 1.26 2005-09-20 13:14:28 claes Exp $
* Proview $Id: wb_wtt.cpp,v 1.27 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -436,6 +436,45 @@ void Wtt::menu_setup()
XtSetValues( menu_classeditor_w, nosensitive, 1);
}
break;
case wb_eType_ExternVolume:
XtUnmanageChild( menu_createstruct_w);
if ( editmode) {
XtSetValues( menu_save_w, sensitive, 1);
XtSetValues( menu_revert_w, sensitive, 1);
XtSetValues( menu_cut_w, sensitive, 1);
XtSetValues( menu_copy_w, sensitive, 1);
XtSetValues( menu_paste_w, sensitive, 1);
XtSetValues( menu_pasteinto_w, sensitive, 1);
XtSetValues( menu_rename_w, sensitive, 1);
XtSetValues( menu_utilities_w, nosensitive, 1);
XtSetValues( menu_openplc_w, nosensitive, 1);
XtSetValues( menu_compile_w, nosensitive, 1);
XtSetValues( menu_createload_w, nosensitive, 1);
XtSetValues( menu_createboot_w, nosensitive, 1);
XtSetValues( menu_distribute_w, nosensitive, 1);
XtSetValues( menu_change_value_w, sensitive, 1);
XtSetValues( menu_edit_w, sensitive, 1);
XtSetValues( menu_classeditor_w, nosensitive, 1);
}
else {
XtSetValues( menu_save_w, nosensitive, 1);
XtSetValues( menu_revert_w, nosensitive, 1);
XtSetValues( menu_cut_w, nosensitive, 1);
XtSetValues( menu_copy_w, nosensitive, 1);
XtSetValues( menu_paste_w, nosensitive, 1);
XtSetValues( menu_pasteinto_w, nosensitive, 1);
XtSetValues( menu_rename_w, nosensitive, 1);
XtSetValues( menu_utilities_w, nosensitive, 1);
XtSetValues( menu_openplc_w, nosensitive, 1);
XtSetValues( menu_compile_w, nosensitive, 1);
XtSetValues( menu_createload_w, nosensitive, 1);
XtSetValues( menu_createboot_w, nosensitive, 1);
XtSetValues( menu_distribute_w, nosensitive, 1);
XtSetValues( menu_change_value_w, nosensitive, 1);
XtSetValues( menu_edit_w, sensitive, 1);
XtSetValues( menu_classeditor_w, nosensitive, 1);
}
break;
default:
;
}
......@@ -452,17 +491,31 @@ int Wtt::restore_settings()
return 1;
}
static char *wtt_script_filename_cb( void *ctx)
{
return ((Wtt *)ctx)->script_filename();
}
char *Wtt::script_filename()
{
static pwr_tFileName fname;
if ( wb_type == wb_eType_Volume)
sprintf( fname, "%s.pwr_com", wnav_cInitFile);
else
sprintf( fname, "%s%d.pwr_com", wnav_cInitFile, (int)wb_type);
dcli_translate_filename( fname, fname);
return fname;
}
int Wtt::save_settings()
{
ofstream fp;
char filename[80];
Arg args[5];
int i;
short width, height;
dcli_get_defaultfilename( wnav_cInitFile, filename, ".pwr_com");
dcli_translate_filename( filename, filename);
fp.open( filename);
fp.open( script_filename());
i = 0;
XtSetArg(args[i], XmNwidth, &width);i++;
......@@ -769,7 +822,8 @@ static void wtt_save_cb( void *ctx)
return;
}
}
wtt->message( 'I', "Session saved");
if ( sts != LDH__CONFIRM)
wtt->message( 'I', "Session saved");
}
static void wtt_revert_ok( Wtt *wtt)
......@@ -1103,10 +1157,22 @@ int Wtt::set_edit()
return 1;
}
if ( !(login_prv.priv & pwr_mPrv_DevConfig))
{
message( 'E', "User is not authorized to configure");
return 1;
switch ( volid) {
case ldh_cProjectListVolume:
case ldh_cGlobalVolumeListVolume:
case ldh_cUserDatabaseVolume:
// Privilege Administrator required
if ( !(login_prv.priv & pwr_mPrv_Administrator)) {
message( 'E', "User is not authorized to administrate");
return 1;
}
break;
default:
// Privilege DevConfig required
if ( !(login_prv.priv & pwr_mPrv_DevConfig)) {
message( 'E', "User is not authorized to configure");
return 1;
}
}
sts = ldh_CloseSession( ldhses);
......@@ -2089,7 +2155,7 @@ static void wtt_activate_openpl( Widget w, Wtt *wtt, XmAnyCallbackStruct *data)
{
wtt->set_clock_cursor();
if ( wtt->open_volume_cb)
(wtt->open_volume_cb) ( wtt, wb_eType_Volume, "ProjectList", wow_eFileSelType_);
(wtt->open_volume_cb) ( wtt, wb_eType_ExternVolume, "ProjectList", wow_eFileSelType_);
wtt->reset_cursor();
}
......@@ -2097,7 +2163,7 @@ static void wtt_activate_opengvl( Widget w, Wtt *wtt, XmAnyCallbackStruct *data)
{
wtt->set_clock_cursor();
if ( wtt->open_volume_cb)
(wtt->open_volume_cb) ( wtt, wb_eType_Volume, "GlobalVolumeList", wow_eFileSelType_);
(wtt->open_volume_cb) ( wtt, wb_eType_ExternVolume, "GlobalVolumeList", wow_eFileSelType_);
wtt->reset_cursor();
}
......@@ -2105,7 +2171,7 @@ static void wtt_activate_openudb( Widget w, Wtt *wtt, XmAnyCallbackStruct *data)
{
wtt->set_clock_cursor();
if ( wtt->open_volume_cb)
(wtt->open_volume_cb) ( wtt, wb_eType_Volume, "UserDatabase", wow_eFileSelType_);
(wtt->open_volume_cb) ( wtt, wb_eType_ExternVolume, "UserDatabase", wow_eFileSelType_);
wtt->reset_cursor();
}
......@@ -3322,6 +3388,7 @@ Wtt::Wtt(
char layout_palette[80];
char title_w1[40];
char title_w2[40];
int hide_wnavnode = 0;
static char translations[] = "\
<FocusIn>: wtt_inputfocus()\n";
......@@ -3489,7 +3556,51 @@ Wtt::Wtt(
strcpy( title_w1, "Plant Configuration");
strcpy( title_w2, "Node Configuration");
sprintf( title, "PwR Navigator Buffer %s, %s", volname, name);
hide_wnavnode = 1;
break;
case pwr_eClass_ExternVolume: {
switch ( volid) {
case ldh_cProjectListVolume:
wb_type = wb_eType_ExternVolume;
strcpy( layout_w1, "PrListNavigatorW1");
strcpy( layout_w2, "PrListNavigatorW1");
strcpy( layout_palette, "PrListNavigatorPalette");
strcpy( title_w1, "Project List");
strcpy( title_w2, "");
sprintf( title, "PwR Project List");
hide_wnavnode = 1;
break;
case ldh_cGlobalVolumeListVolume:
wb_type = wb_eType_ExternVolume;
strcpy( layout_w1, "GvListNavigatorW1");
strcpy( layout_w2, "GvListNavigatorW1");
strcpy( layout_palette, "GvListNavigatorPalette");
strcpy( title_w1, "Global Volume List");
strcpy( title_w2, "");
sprintf( title, "PwR Global Volume List");
hide_wnavnode = 1;
break;
case ldh_cUserDatabaseVolume:
wb_type = wb_eType_ExternVolume;
strcpy( layout_w1, "UserDbNavigatorW1");
strcpy( layout_w2, "UserDbNavigatorW1");
strcpy( layout_palette, "UserDbNavigatorPalette");
strcpy( title_w1, "User Database");
strcpy( title_w2, "");
sprintf( title, "PwR User Database");
hide_wnavnode = 1;
break;
default:
wb_type = wb_eType_ExternVolume;
strcpy( layout_w1, "NavigatorW1");
strcpy( layout_w2, "NavigatorW2");
strcpy( layout_palette, "NavigatorPalette");
strcpy( title_w1, "Plant Configuration");
strcpy( title_w2, "Node Configuration");
sprintf( title, "PwR Navigator Volume %s, %s", volname, name);
}
break;
}
default:
wb_type = wb_eType_Volume;
strcpy( layout_w1, "NavigatorW1");
......@@ -3580,6 +3691,7 @@ Wtt::Wtt(
wnav->create_popup_menu_cb = &wtt_create_popup_menu_cb;
wnav->save_cb = &wtt_save_cb;
wnav->revert_cb = &wtt_revert_cb;
wnav->script_filename_cb = &wtt_script_filename_cb;
wnav->format_selection_cb = wtt_format_selection;
wnav->get_global_select_cb = wtt_get_global_select_cb;
wnav->global_unselect_objid_cb = wtt_global_unselect_objid_cb;
......@@ -3611,6 +3723,7 @@ Wtt::Wtt(
wnavnode->create_popup_menu_cb = &wtt_create_popup_menu_cb;
wnavnode->save_cb = &wtt_save_cb;
wnavnode->revert_cb = &wtt_revert_cb;
wnavnode->script_filename_cb = &wtt_script_filename_cb;
wnavnode->format_selection_cb = wtt_format_selection;
wnavnode->get_global_select_cb = wtt_get_global_select_cb;
wnavnode->global_unselect_objid_cb = wtt_global_unselect_objid_cb;
......
/*
* Proview $Id: wb_wtt.h,v 1.13 2005-09-20 13:14:28 claes Exp $
* Proview $Id: wb_wtt.h,v 1.14 2005-10-25 12:04:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -267,6 +267,7 @@ class Wtt {
void pop();
int find( pwr_tOid oid);
int find_plc( pwr_tOid oid);
char *script_filename();
~Wtt();
};
......
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