Commit 7a20e851 authored by claes's avatar claes

More work on sev

parent 532e423f
This diff is collapsed.
/*
* Proview $Id: ini.h,v 1.1 2008-09-05 08:38:58 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.
*/
#ifndef ini_h
#define ini_h
#include "pwr.h"
#include "pwr_class.h"
#include "pwr_baseclasses.h"
#include "co_tree.h"
#include "co_dbs.h"
#include "rt_lst.h"
#include "rt_qini.h"
#include "rt_proc.h"
#include "rt_errh.h"
typedef union {
pwr_tBitMask m;
pwr_32Bits (
pwr_Bits( ignoreWarning , 1),
pwr_Bits( ignoreError , 1),
pwr_Bits( ignoreFatal , 1),
pwr_Bits( verbose , 1),
pwr_Bits( restart , 1),
pwr_Bits( stop , 1),
pwr_Bits( fill_0 , 2),,,
pwr_Bits( interactive , 1),
pwr_Bits( busid , 1),
pwr_Bits( hostname , 1),
pwr_Bits( nodename , 1),
pwr_Bits( fill_1 , 4),,,,
pwr_Bits( applfile , 1),
pwr_Bits( aliasfile , 1),
pwr_Bits( bootfile , 1),
pwr_Bits( plcfile , 1),
pwr_Bits( nodefile , 1),
pwr_Bits( fill_2 , 3),,,
pwr_Bits( fill_3 , 8),,,,,,
) b;
#define ini_mContext__ 0
#define ini_mContext_ignoreWarning pwr_Bit(0)
#define ini_mContext_ignoreError pwr_Bit(1)
#define ini_mContext_ignoreFatal pwr_Bit(2)
#define ini_mContext_verbose pwr_Bit(3)
#define ini_mContext_restart pwr_Bit(4)
#define ini_mContext_stop pwr_Bit(5)
#define ini_mContext_interactive pwr_Bit(8)
#define ini_mContext_busid pwr_Bit(9)
#define ini_mContext_hostname pwr_Bit(10)
#define ini_mContext_nodename pwr_Bit(11)
#define ini_mContext_applfile pwr_Bit(16)
#define ini_mContext_aliasfile pwr_Bit(17)
#define ini_mContext_bootfile pwr_Bit(18)
#define ini_mContext_plcfile pwr_Bit(19)
#define ini_mContext_nodefile pwr_Bit(20)
#define ini_mContext_ (~ini_mContext__)
} ini_mContext;
typedef union {
pwr_tBitMask m;
pwr_32Bits (
pwr_Bits( neth , 1),
pwr_Bits( qmon , 1),
pwr_Bits( plc , 1),
pwr_Bits( fill_0 , 5),,,,,
pwr_Bits( run , 1),
pwr_Bits( running , 1),
pwr_Bits( reap , 1),
pwr_Bits( fill_1 , 5),,,,,
pwr_Bits( fill_2 , 8),,,,,,,,
pwr_Bits( inited , 1),
pwr_Bits( fill_3 , 8),,,,,,
) b;
#define ini_mProc__ 0
#define ini_mProc_neth pwr_Bit(0)
#define ini_mProc_qmon pwr_Bit(1)
#define ini_mProc_plc pwr_Bit(2)
#define ini_mProc_run pwr_Bit(8)
#define ini_mProc_running pwr_Bit(9)
#define ini_mProc_reap pwr_Bit(10)
#define ini_mProc_inited pwr_Bit(24)
#define ini_mProc_ (~ini_mProc__)
} ini_mProc;
typedef struct {
char name[256];
int *errcount;
void (*logOpenFail)(errh_sLog*, char*, ...);
} ini_sFile;
typedef struct {
tree_sNode t;
lst_sEntry proc_ll;
char id[40];
ini_mProc flags;
proc_sProcess proc;
} ini_sProc;
typedef struct {
ini_mContext flags;
char alias[80];
char nodename[80];
char nodespec[80];
char hostname[80];
char hostspec[80];
char bootdisk[80];
char proj[80];
char group[80];
char console[80];
ini_sFile aliasfile;
ini_sFile applfile;
ini_sFile bootfile;
ini_sFile nodefile;
int busid;
char dir[256];
char bdir[256]; /* Base dir (pwr_load) */
int warnings;
int errors;
int fatals;
qini_sNode *me;
tree_sTable *nid_t;
co_mFormat format;
dbs_sEnv dbs;
dbs_sSect sect;
tree_sTable *proc_t;
lst_sEntry proc_lh;
ini_sProc *plc;
qcom_sQid myQ;
qcom_sQid yourQ;
qcom_sQid eventQ;
errh_sLog log;
} ini_sContext;
ini_sContext *ini_CheckContext (pwr_tStatus*, ini_sContext*);
ini_sContext *ini_CreateContext (pwr_tStatus*);
char * ini_LoadDirectory (pwr_tStatus*, ini_sContext*);
FILE *ini_OpenFile (pwr_tStatus*, ini_sContext*, ini_sFile*);
ini_sProc *ini_ProcInsert (pwr_tStatus*, ini_sContext*, char*, char*, int, int, char*, int, int, char*);
void ini_ProcIter (pwr_tStatus*, ini_sContext*, int,
void (*func) (pwr_tStatus*, ini_sContext*, ini_sProc*));
void ini_ProcStart (pwr_tStatus*, ini_sContext*, ini_sProc*);
void ini_ProcPrio (pwr_tStatus*, ini_sContext*, ini_sProc*);
void ini_ProcTable (pwr_tStatus*, ini_sContext*);
void ini_ProcWait (pwr_tStatus*, ini_sContext*);
void ini_ReadBootFile (pwr_tStatus*, ini_sContext*);
pwr_tBoolean ini_ReadNodeFile (pwr_tStatus*, ini_sContext*);
#endif
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
ifndef link_rule_mk
link_rule_mk := 1
link = $(ldxx) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(wb_msg_eobjs) $(rt_msg_eobjs) \
$(pwr_eobj)/rt_io_user.o \
-lpwr_sev -lpwr_rt -lpwr_co $(linkmysql)\
-lpwr_msg_dummy \
-lrpcsvc -lpthread -lm -lrt -ldb_cxx -lz -lcrypt
#-lpwr_wb -lpwr_rt -lpwr_ge -lpwr_flow -lpwr_glow -lpwr_co \
# -L/usr/X11R6/lib -L/usr/local/BerkeleyDB.4.0/lib \
# -L/opt/gnome/lib \
# -lantlr -lImlib -lMrm -lXm -lXpm -lXt -lX11 -lXext -lXp\
# -lXmu -lSM -lICE\
endif
This diff is collapsed.
/*
* Proview $Id: sev_server.cpp,v 1.1 2008-07-17 11:18:31 claes Exp $
* Proview $Id: sev_server.cpp,v 1.2 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -22,8 +22,10 @@
#include "co_dcli.h"
#include "co_time.h"
#include "co_error.h"
#include "co_cnf.h"
#include "rt_qcom.h"
#include "rt_qcom_msg.h"
#include "rt_ini_event.h"
#include "sev_server.h"
#include "rt_sev_net.h"
#include "sev_dbms.h"
......@@ -37,6 +39,7 @@ int sev_server::init()
pwr_tNid nid;
pwr_tStatus sts;
qcom_sAid aid;
qcom_sQid qini;
m_db->get_items( &m_sts);
......@@ -61,15 +64,18 @@ int sev_server::init()
if ( sts == QCOM__QALLREXIST) {
if ( !qcom_AttachQ(&sts, &qid)) {
if ( !qcom_DeleteQ(&sts, &qid))
co_error(sts);
throw co_error(sts);
if ( !qcom_CreateQ(&sts, &qid, &attr, "SevServer"))
co_error(sts);
throw co_error(sts);
}
}
else
throw co_error( sts);
}
qini = qcom_cQini;
if (!qcom_Bind(&sts, &qid, &qini))
throw co_error(sts);
// Get all qcom nodes
qcom_MyNode( &m_sts, &node);
......@@ -160,7 +166,12 @@ int sev_server::send_itemlist( qcom_sQid tgt)
pwr_tStatus sts, lsts;
int size;
item_cnt = m_db->m_items.size();
for ( unsigned int i = 0; i < m_db->m_items.size(); i++) {
if ( m_db->m_items[i].deleted)
continue;
item_cnt++;
}
if ( !item_cnt)
return 1;
......@@ -171,19 +182,23 @@ int sev_server::send_itemlist( qcom_sQid tgt)
((sev_sMsgHistItems *)put.data)->Type = sev_eMsgType_HistItems;
int idx = 0;
for ( unsigned int i = 0; i < m_db->m_items.size(); i++) {
((sev_sMsgHistItems *)put.data)->Items[i].oid = m_db->m_items[i].oid;
strcpy( ((sev_sMsgHistItems *)put.data)->Items[i].oname, m_db->m_items[i].oname);
strcpy( ((sev_sMsgHistItems *)put.data)->Items[i].aname, m_db->m_items[i].aname);
((sev_sMsgHistItems *)put.data)->Items[i].storagetime = m_db->m_items[i].storagetime;
((sev_sMsgHistItems *)put.data)->Items[i].type = m_db->m_items[i].vtype;
((sev_sMsgHistItems *)put.data)->Items[i].size = m_db->m_items[i].vsize;
strcpy( ((sev_sMsgHistItems *)put.data)->Items[i].description, m_db->m_items[i].description);
strcpy( ((sev_sMsgHistItems *)put.data)->Items[i].unit, m_db->m_items[i].unit);
((sev_sMsgHistItems *)put.data)->Items[i].scantime = m_db->m_items[i].scantime;
if ( m_db->m_items[i].deleted)
continue;
((sev_sMsgHistItems *)put.data)->Items[idx].oid = m_db->m_items[i].oid;
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].oname, m_db->m_items[i].oname);
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].aname, m_db->m_items[i].aname);
((sev_sMsgHistItems *)put.data)->Items[idx].storagetime = m_db->m_items[i].storagetime;
((sev_sMsgHistItems *)put.data)->Items[idx].type = m_db->m_items[i].vtype;
((sev_sMsgHistItems *)put.data)->Items[idx].size = m_db->m_items[i].vsize;
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].description, m_db->m_items[i].description);
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].unit, m_db->m_items[i].unit);
((sev_sMsgHistItems *)put.data)->Items[idx].scantime = m_db->m_items[i].scantime;
idx++;
}
if ( m_db->m_items.size() == 0)
if ( !item_cnt)
((sev_sMsgHistItems *)put.data)->Status = SEV__NOITEMS;
else
((sev_sMsgHistItems *)put.data)->Status = SEV__SUCCESS;
......@@ -201,6 +216,35 @@ int sev_server::send_itemlist( qcom_sQid tgt)
return 1;
}
int sev_server::delete_item( qcom_sQid tgt, sev_sMsgHistItemDelete *rmsg)
{
qcom_sPut put;
pwr_tStatus sts, lsts;
put.size = sizeof(sev_sMsgHistItemStatus);
put.data = qcom_Alloc(&lsts, put.size);
m_db->delete_item( &sts, rmsg->Oid, rmsg->AName);
((sev_sMsgHistItemStatus *)put.data)->Type = sev_eMsgType_HistItemStatus;
((sev_sMsgHistItemStatus *)put.data)->Oid = rmsg->Oid;
strcpy( ((sev_sMsgHistItemStatus *)put.data)->AName, rmsg->AName);
((sev_sMsgHistItemStatus *)put.data)->Status = sts;
put.reply.nid = m_nodes[0].nid;
put.reply.qix = sev_eProcSevServer;
put.type.b = (qcom_eBtype) sev_cMsgClass;
put.type.s = (qcom_eStype) sev_eMsgType_HistItemStatus;
put.msg_id = m_msg_id++;
if ( !qcom_Put( &sts, &tgt, &put)) {
qcom_Free( &sts, put.data);
return 0;
}
return 1;
}
int sev_server::mainloop()
{
qcom_sQid qid;
......@@ -250,9 +294,21 @@ int sev_server::mainloop()
case sev_eMsgType_HistItemsRequest:
send_itemlist( get.reply);
break;
case sev_eMsgType_HistItemDelete:
delete_item( get.reply, (sev_sMsgHistItemDelete *) mp);
break;
default: ;
}
break;
case qcom_eBtype_event: {
ini_mEvent new_event;
qcom_sEvent *ep = (qcom_sEvent*) get.data;
new_event.m = ep->mask;
if (new_event.b.terminate)
exit(0);
break;
}
default: ;
}
......@@ -392,6 +448,8 @@ void sev_server::garbage_collector()
clock_gettime( CLOCK_REALTIME, &currenttime);
for ( unsigned int i = 0; i < m_db->m_items.size(); i++) {
if ( m_db->m_items[i].deleted)
continue;
if ( m_db->m_items[i].storagetime.tv_sec == 0)
continue;
......@@ -407,6 +465,7 @@ int main()
sev_dbms_env *env;
pwr_tFileName envname;
char socket[200];
sprintf( envname, "$pwrp_db/%s.db", sev_dbms_env::dbName());
dcli_translate_filename( envname, envname);
......@@ -414,8 +473,9 @@ int main()
env = new sev_dbms_env( envname);
env->open( envname);
if ( !env->exists()) {
env->create( envname, "aristotle", "pwrp", "", sev_dbms_env::dbName(), 50,
"/var/run/mysqld/mysqld.sock");
cnf_get_value( "mysqlSocket", socket);
env->create( envname, "localhost", "pwrp", "", sev_dbms_env::dbName(), 50,
socket);
env->open( envname);
......
/*
* Proview $Id: sev_server.h,v 1.1 2008-07-17 11:18:31 claes Exp $
* Proview $Id: sev_server.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -88,6 +88,7 @@ class sev_server {
int receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size);
int send_histdata( qcom_sQid tgt, sev_sMsgHistDataGetRequest *msg, unsigned int size);
int send_itemlist( qcom_sQid tgt);
int delete_item( qcom_sQid tgt, sev_sMsgHistItemDelete *rmsg);
void garbage_collector();
};
#endif
......@@ -4,7 +4,7 @@ link_rule_mk := 1
link = $(ldxx) $(elinkflags) $(domap) -o $(pwr_exe)/sev_xtt_gtk \
$(bld_dir)/sev_xtt_gtk.o \
$(bld_dir)/xtt_tbl_gtk.o $(bld_dir)/xtt_tblnav_gtk.o $(bld_dir)/xtt_tbl.o \
$(bld_dir)/xtt_tblnav.o \
$(bld_dir)/xtt_tblnav.o $(bld_dir)/xtt_tbl_command.o \
$(rt_msg_eobjs) \
$(pwr_eobj)/rt_io_user.o -L/usr/X11R6/lib\
-L/opt/gnome/lib \
......
/*
* Proview $Id: sev_xtt_gtk.cpp,v 1.1 2008-07-17 11:18:31 claes Exp $
* Proview $Id: sev_xtt_gtk.cpp,v 1.2 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -18,15 +18,25 @@
*/
#include <fstream.h>
#include <vector.h>
#include <gtk/gtk.h>
#include "pwr.h"
#include "pwr_class.h"
#include "xtt_tbl_gtk.h"
#include "co_error.h"
#include "rt_qcom.h"
#include "rt_errh.h"
#include "rt_sevcli.h"
#include "xtt_tbl_gtk.h"
void tbl_close_cb( void *tbl)
{
XttTblGtk *xtttbl = (XttTblGtk *)tbl;
delete xtttbl;
exit(0);
}
int main( int argc, char *argv[])
{
......@@ -49,17 +59,24 @@ int main( int argc, char *argv[])
if ( EVEN(sts)) co_error(sts);
sevcli_init( &sts, &sevcli);
if ( EVEN(sts)) co_error(sts);
if ( EVEN(sts)) {
printf( "Sev client init error %u\n", sts);
exit(0);
}
if ( strcmp(servername, "") != 0)
sevcli_set_servernode( &sts, sevcli, servername);
sevcli_get_itemlist( &sts, sevcli, &items, &itemcnt);
if ( EVEN(sts)) co_error(sts);
if ( EVEN(sts)) {
printf( "Sev client get itemlist error %u\n", sts);
exit(0);
}
gtk_init( &argc, &argv);
new XttTblGtk( 0, 0, sevcli, items, itemcnt);
XttTblGtk *tbl = new XttTblGtk( 0, 0, sevcli, items, itemcnt);
tbl->close_cb = tbl_close_cb;
gtk_main();
return 1;
......
This diff is collapsed.
/*
* Proview $Id: xtt_tbl_gtk.h,v 1.1 2008-07-17 11:18:31 claes Exp $
* Proview $Id: xtt_tbl_gtk.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -26,6 +26,8 @@
/* ge_tbl.h -- Ge tblibute editor */
class CoWowRecall;
class CoWowEntryGtk;
class XttTblGtk : public XttTbl {
public:
......@@ -40,10 +42,37 @@ class XttTblGtk : public XttTbl {
GtkWidget *form_widget;
GtkWidget *toplevel;
GtkWidget *msg_label;
GtkWidget *cmd_prompt;
GtkWidget *cmd_input;
GtkWidget *pane;
CoWowRecall *cmd_recall;
CoWowEntryGtk *cmd_entry;
void message( char severity, char *message);
XttDsHist *dshist_new( pwr_tOid oid, char *aname);
CoLogin *login_new( char *wl_name,
char *wl_groupname,
void (* wl_bc_success)( void *),
void (* wl_bc_cancel)( void *),
pwr_tStatus *status);
void set_prompt( char *prompt);
static void activate_command( GtkWidget *w, gpointer data);
static void valchanged_cmd_input( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_login( GtkWidget *w, gpointer data);
static void activate_logout( GtkWidget *w, gpointer data);
static void activate_close( GtkWidget *w, gpointer data);
static void activate_opendshist( GtkWidget *w, gpointer data);
static void activate_delete_item( GtkWidget *w, gpointer data);
static void activate_tree_layout( GtkWidget *w, gpointer data);
static void activate_list_layout( GtkWidget *w, gpointer data);
static void activate_zoom_in( GtkWidget *w, gpointer data);
static void activate_zoom_out( GtkWidget *w, gpointer data);
static void activate_zoom_reset( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static void activate_help_project( GtkWidget *w, gpointer data);
static void activate_help_proview( GtkWidget *w, gpointer data);
~XttTblGtk();
};
......
/*
* Proview $Id: xtt_tbl.cpp,v 1.1 2008-07-17 11:18:31 claes Exp $
* Proview $Id: xtt_tbl.cpp,v 1.2 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -26,6 +26,10 @@
#include <vector.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_xhelp.h"
#include "co_dcli.h"
#include "co_wow.h"
#include "co_cnf.h"
#include "flow.h"
#include "flow_browctx.h"
......@@ -44,8 +48,28 @@ XttTbl::~XttTbl()
}
XttTbl::XttTbl( void *xn_parent_ctx, sevcli_tCtx xn_sevcli) :
parent_ctx(xn_parent_ctx), sevcli(xn_sevcli)
parent_ctx(xn_parent_ctx), sevcli(xn_sevcli), command_open(0), close_cb(0),
base_priv(pwr_mPrv_System), priv(pwr_mPrv_System), verify(0), ccm_func_registred(0),
quiet(0)
{
char default_priv[80];
strcpy( base_user, "");
strcpy( user, "");
// Get default privilete from proview.cnf
if ( cnf_get_value( "sevXttDefaultPriv", default_priv)) {
if ( cdh_NoCaseStrcmp( default_priv, "READ") == 0)
priv = pwr_mPrv_SevRead;
else if ( cdh_NoCaseStrcmp( default_priv, "ADMIN") == 0)
priv = pwr_mPrv_SevAdmin;
else if ( cdh_NoCaseStrcmp( default_priv, "NONE") == 0)
priv = 0;
else
priv = 0;
}
else
priv = 0;
}
void XttTbl::message( void *xtttbl, char severity, char *message)
......@@ -53,6 +77,47 @@ void XttTbl::message( void *xtttbl, char severity, char *message)
((XttTbl *)xtttbl)->message( severity, message);
}
int XttTbl::is_authorized( void *ctx, unsigned int access, int msg)
{
return ((XttTbl *)ctx)->is_authorized( access, msg);
}
int XttTbl::is_authorized( unsigned int access, int msg)
{
if (!(priv & access)) {
if ( msg)
message( 'I', "Not authorized for this operation");
return 0;
}
return 1;
}
void XttTbl::open_login()
{
pwr_tCmd cmd;
strcpy( cmd, "login");
command( cmd);
}
void XttTbl::logout()
{
pwr_tCmd cmd;
strcpy( cmd, "logout");
command( cmd);
}
void XttTbl::activate_print()
{
pwr_tFileName filename;
pwr_tCmd cmd;
dcli_translate_filename( filename, "$pwrp_tmp/sevxtt.ps");
tblnav->print( filename);
sprintf( cmd, "$pwr_exe/rt_print.sh %s", filename);
system(cmd);
}
void XttTbl::activate_opendshist()
{
sevcli_sHistItem *hi;
......@@ -61,3 +126,78 @@ void XttTbl::activate_opendshist()
dshist_new( hi->oid, hi->aname);
}
void XttTbl::delete_item_yes( void *ctx, void *data)
{
XttTbl *tbl = (XttTbl *)ctx;
sevcli_sHistItem *hi = (sevcli_sHistItem *)data;
pwr_tStatus sts;
printf("Deleting %s\n", hi->oname);
sevcli_delete_item( &sts, tbl->sevcli, hi->oid, hi->aname);
if ( EVEN(sts)) {
tbl->message( 'E', "Delete error");
return;
}
tbl->tblnav->delete_item( hi);
tbl->message( 'I', "Item deleted");
}
void XttTbl::activate_delete_item()
{
sevcli_sHistItem *hi;
char msg[300];
if ( !tblnav->get_select( &hi)) {
message( 'E', "Select an storage item");
return;
}
sprintf( msg, "Do you really wan't to delete all stored data for item\n\n%s.%s\n", hi->oname, hi->aname);
wow->DisplayQuestion( this, "Confirm Delete Item", msg, delete_item_yes, 0, hi);
}
void XttTbl::activate_zoom_in()
{
double zoom_factor;
tblnav->get_zoom( &zoom_factor);
if ( zoom_factor > 40)
return;
tblnav->zoom( 1.18);
}
void XttTbl::activate_zoom_out()
{
double zoom_factor;
tblnav->get_zoom( &zoom_factor);
if ( zoom_factor < 15)
return;
tblnav->zoom( 1.0 / 1.18);
}
void XttTbl::activate_zoom_reset()
{
tblnav->unzoom();
}
void XttTbl::activate_help()
{
CoXHelp::dhelp("overview", "", navh_eHelpFile_Base, NULL, 0);
}
void XttTbl::activate_help_project()
{
CoXHelp::dhelp("index", "", navh_eHelpFile_Project, NULL, 0);
}
void XttTbl::activate_help_proview()
{
CoXHelp::dhelp( "version", "", navh_eHelpFile_Other, "$pwr_exe/sev_xtt_version_help.dat", 0);
}
/*
* Proview $Id: xtt_tbl.h,v 1.1 2008-07-17 11:18:31 claes Exp $
* Proview $Id: xtt_tbl.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -20,6 +20,10 @@
#ifndef xtt_tbl_h
#define xtt_tbl_h
#ifndef pwr_privilege_h
#include "pwr_privilege.h"
#endif
#include "glow.h"
#include "rt_sevcli.h"
......@@ -28,6 +32,8 @@
class TblNav;
class XttDsHist;
class CoLogin;
class CoWow;
class XttTbl {
public:
......@@ -36,13 +42,49 @@ class XttTbl {
char name[80];
TblNav *tblnav;
sevcli_tCtx sevcli;
CoLogin *cologin;
int command_open;
void (*close_cb)( void *);
char base_user[80];
char user[80];
unsigned int base_priv;
unsigned int priv;
int verify;
int ccm_func_registred;
CoWow *wow;
int quiet;
virtual void message( char severity, char *message) {}
virtual XttDsHist *dshist_new( pwr_tOid oid, char *aname) { return 0;}
virtual CoLogin *login_new( char *wl_name,
char *wl_groupname,
void (* wl_bc_success)( void *),
void (* wl_bc_cancel)( void *),
pwr_tStatus *status) { return 0;}
virtual void set_prompt( char *prompt) {}
int is_authorized( unsigned int access = pwr_mAccess_AllSev, int msg = 1);
void open_login();
void logout();
void activate_print();
void activate_opendshist();
void activate_delete_item();
void activate_zoom_in();
void activate_zoom_out();
void activate_zoom_reset();
void activate_help();
void activate_help_project();
void activate_help_proview();
static void message( void *attr, char severity, char *message);
static int is_authorized( void *ctx, unsigned int access, int msg);
static void delete_item_yes( void *ctx, void *data);
virtual ~XttTbl();
int command( char* input_str);
int readcmdfile( char *incommand);
int read_bootfile( char *systemname, char *systemgroup);
};
......
This diff is collapsed.
This diff is collapsed.
/*
* Proview $Id: xtt_tblnav.h,v 1.1 2008-07-17 11:18:31 claes Exp $
* Proview $Id: xtt_tblnav.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -22,10 +22,17 @@
/* xtt_attrnav.h -- Sev Table Viewer */
#include <fstream.h>
#include <vector.h>
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef pwr_privilege_h
#include "pwr_privilege.h"
#endif
#ifndef flow_h
#include "flow.h"
#endif
......@@ -45,15 +52,31 @@
typedef enum {
tblnav_eItemType_Local,
tblnav_eItemType_LocalAttr
tblnav_eItemType_LocalAttr,
tblnav_eItemType_TreeLocal,
tblnav_eItemType_TreeNode
} tblnav_eItemType;
typedef enum {
tblnav_mOpen_All = ~0,
tblnav_mOpen_Children = 1 << 0,
tblnav_mOpen_Attributes = 1 << 1
} tblnav_mOpen;
class TblTreeNode {
public:
TblTreeNode() : fth(0), fch(0), fws(0), bws(0), item(0), deleted(0)
{ strcpy( sname, "");}
int fth;
int fch;
int fws;
int bws;
char sname[80];
sevcli_sHistItem *item;
int deleted;
};
//! Class for handling of brow.
class TblNavBrow {
public:
......@@ -91,35 +114,79 @@ class TblNav {
sevcli_sHistItem *itemlist;
int item_cnt;
void (*message_cb)( void *, char, char *);
int (*is_authorized_cb)( void *, unsigned int, int);
vector<TblTreeNode> tree;
int list_layout;
void print( char *filename);
int is_authorized( unsigned int access = pwr_mAccess_AllSev, int msg = 1);
int create_items();
void build_tree();
int get_select( sevcli_sHistItem **hi);
void get_zoom( double *zoom_factor);
void zoom( double zoom_factor);
void unzoom();
void show_tree();
void show_list();
void delete_item( sevcli_sHistItem *hi);
virtual void message( char sev, char *text);
virtual void set_inputfocus() {}
static int init_brow_cb( FlowCtx *fctx, void *client_data);
};
class ItemBase {
public:
ItemBase( tblnav_eItemType t) : type(t) {}
virtual ~ItemBase() {}
tblnav_eItemType type;
virtual int close( TblNav *tblnav, double x, double y) {return 1;}
};
//! Item for a normal attribute.
class ItemLocal {
class ItemLocal : public ItemBase {
public:
ItemLocal( TblNav *tblnav, sevcli_sHistItem *item, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemLocal() {}
sevcli_sHistItem item;
tblnav_eItemType type;
brow_tNode node;
int open_attributes( TblNav *tblnav, double x, double y);
int close( TblNav *tblnav, double x, double y);
};
class ItemLocalAttr {
class ItemLocalAttr : public ItemBase {
public:
ItemLocalAttr( TblNav *tblnav, char *iname, char *ivalue, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemLocalAttr() {}
sevcli_sHistItem item;
tblnav_eItemType type;
brow_tNode node;
};
//! Item for a normal attribute.
class ItemTreeLocal : public ItemLocal {
public:
ItemTreeLocal( TblNav *tblnav, sevcli_sHistItem *item, int index, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemTreeLocal() {}
int idx;
};
//! Item for a normal attribute.
class ItemTreeNode : public ItemBase {
public:
ItemTreeNode( TblNav *tblnav, char *name, int index, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemTreeNode() {}
brow_tNode node;
int idx;
int open_children( TblNav *tblnav, double x, double y);
int close( TblNav *tblnav, double x, double y);
};
#endif
/*
* Proview $Id: sev_db.h,v 1.1 2008-07-17 11:18:31 claes Exp $
* Proview $Id: sev_db.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -28,7 +28,7 @@
class sev_item {
public:
sev_item() {}
sev_item() : deleted(0) {}
unsigned int id;
char tablename[256];
pwr_tOid oid;
......@@ -43,6 +43,7 @@ class sev_item {
pwr_tString80 description;
pwr_tString16 unit;
pwr_tFloat32 scantime;
int deleted;
};
......@@ -60,6 +61,7 @@ class sev_db {
pwr_tDeltaTime storagetime, pwr_eType type, unsigned int size,
char *description, char *unit, pwr_tFloat32 scantime, unsigned int *idx)
{ return 0;}
virtual int delete_item( pwr_tStatus *sts, pwr_tOid oid, char *aname) { return 0;}
virtual int store_value( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eType type,
pwr_tTime time, void *buf, unsigned int size) { return 0;}
virtual int get_values( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eType type,
......
/*
* Proview $Id: sev_dbms.cpp,v 1.1 2008-07-17 11:18:31 claes Exp $
* Proview $Id: sev_dbms.cpp,v 1.2 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -446,6 +446,22 @@ int sev_dbms::create_table( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eTy
return 1;
}
int sev_dbms::delete_table( pwr_tStatus *sts, pwr_tOid oid, char *aname)
{
char query[200];
sprintf( query, "drop table %s;",
oid_to_table(oid, aname));
int rc = mysql_query( m_env->con(), query);
if (rc) {
printf( "Delete table: %s\n", mysql_error(m_env->con()));
*sts = SEV__DBERROR;
return 0;
}
return 1;
}
int sev_dbms::store_item( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *oname,
char *aname, pwr_tDeltaTime storagetime, pwr_eType vtype,
unsigned int vsize, char *description, char *unit, pwr_tFloat32 scantime)
......@@ -473,6 +489,23 @@ int sev_dbms::store_item( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char
return 1;
}
int sev_dbms::remove_item( pwr_tStatus *sts, pwr_tOid oid, char *aname)
{
char query[800];
sprintf( query, "delete from items where vid = %u and oix = %u and aname = '%s';",
oid.vid, oid.oix, aname);
int rc = mysql_query( m_env->con(), query);
if (rc) {
printf( "Remove item: %s\n", mysql_error(m_env->con()));
*sts = SEV__DBERROR;
return 0;
}
*sts = SEV__SUCCESS;
return 1;
}
int sev_dbms::get_items( pwr_tStatus *sts)
{
m_items.clear();
......@@ -761,6 +794,9 @@ int sev_dbms::check_item( pwr_tStatus *sts, pwr_tOid oid, char *oname, char *ana
timestr[19] = 0;
for ( unsigned int i = 0; i < m_items.size(); i++) {
if ( m_items[i].deleted)
continue;
if ( cdh_ObjidIsEqual( oid, m_items[i].oid) &&
cdh_NoCaseStrcmp( aname, m_items[i].aname) == 0) {
char query[400];
......@@ -830,6 +866,31 @@ int sev_dbms::add_item( pwr_tStatus *sts, pwr_tOid oid, char *oname, char *aname
return 1;
}
int sev_dbms::delete_item( pwr_tStatus *sts, pwr_tOid oid, char *aname)
{
char tablename[256];
strcpy( tablename, oid_to_table( oid, aname));
remove_item( sts, oid, aname);
if ( ODD(*sts))
delete_table( sts, oid, aname);
if ( ODD(*sts)) {
for ( int i = 0; i < (int)m_items.size(); i++) {
if ( m_items[i].deleted)
continue;
if ( cdh_ObjidIsEqual( m_items[i].oid, oid) &&
cdh_NoCaseStrcmp( m_items[i].aname, aname) == 0) {
m_items[i].deleted = 1;
break;
}
}
}
return 1;
}
int sev_dbms::delete_old_data( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_tTime limit)
{
char query[300];
......
/*
* Proview $Id: sev_dbms.h,v 1.1 2008-07-17 11:18:31 claes Exp $
* Proview $Id: sev_dbms.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -115,12 +115,15 @@ class sev_dbms : public sev_db {
pwr_tFloat32 scantime, pwr_tTime *starttime, pwr_tTime *endtime,
int maxsize, pwr_tTime **tbuf, void **vbuf, unsigned int *bsize);
int delete_old_data( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_tTime limit);
int delete_item( pwr_tStatus *sts, pwr_tOid oid, char *aname);
int get_items( pwr_tStatus *sts);
int create_table( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eType type, unsigned int size);
int delete_table( pwr_tStatus *sts, pwr_tOid oid, char *aname);
int store_item( pwr_tStatus *sts, char *tabelname, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storagetime, pwr_eType vtype, unsigned int vsize,
char *description, char *unit, pwr_tFloat32 scantime);
int remove_item( pwr_tStatus *sts, pwr_tOid oid, char *aname);
char *oid_to_table( pwr_tOid oid, char *aname);
char *pwrtype_to_type( pwr_eType type, unsigned int size);
static int timestr_to_time( char *tstr, pwr_tTime *ts);
......
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