From 0bb0e6e7668a35b838c964f307656c4b1763d64a Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Wed, 27 Jul 2022 17:48:35 -0400 Subject: [PATCH] 2022-07-27 Fred Gleason * Fixed a bug in rdadmin(1) that permitted immutable switcher endpoint names to be edited. Signed-off-by: Fred Gleason --- ChangeLog | 3 ++ lib/rdendpointlistmodel.cpp | 1 - lib/rdmatrix.cpp | 57 ++++++++++++++++++++++++++++++++++++- lib/rdmatrix.h | 1 + rdadmin/list_endpoints.cpp | 9 ++++-- rdadmin/list_endpoints.h | 2 +- 6 files changed, 67 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48e60eca..7ad89fd4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23197,3 +23197,6 @@ * Fixed a bug in the 'Software Authority Protocol' switcher/GPIO driver in ripcd(8) that failed to initialize matrix endpoints correctly at startup. +2022-07-27 Fred Gleason + * Fixed a bug in rdadmin(1) that permitted immutable switcher endpoint + names to be edited. diff --git a/lib/rdendpointlistmodel.cpp b/lib/rdendpointlistmodel.cpp index fa7f0907..d7a04250 100644 --- a/lib/rdendpointlistmodel.cpp +++ b/lib/rdendpointlistmodel.cpp @@ -264,7 +264,6 @@ void RDEndpointListModel::updateModel() d_texts.back().push_back(QVariant()); } } - // printf("SQL: %s\n",sql.toUtf8().constData()); q=new RDSqlQuery(sql); while(q->next()) { d_ids.push_back(-1); diff --git a/lib/rdmatrix.cpp b/lib/rdmatrix.cpp index 0c288d37..c35bb751 100644 --- a/lib/rdmatrix.cpp +++ b/lib/rdmatrix.cpp @@ -2,7 +2,7 @@ // // Abstract a Rivendell Switcher Matrix // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2022 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -177,6 +177,55 @@ int __mx_default_values[RDMatrix::LastType][RDMatrix::LastControl]= {1,0,0,12345,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0} // GVC 7000 }; +int __mx_endpoints_are_editable_values[RDMatrix::LastType]= + { + true, // Local GPIO + true, // Generic GPIO + true, // Generic Serial + true, // SAS 32000 + true, // SAS 64000 + true, // Unity4k + true, // BT SS 8.2 + true, // BT 10x1 + true, // SAS 64000 GPI + true, // BT 16x1 + true, // BT 8x2 + true, // BT ACS 8.2 + false, // SAS USI + true, // BT 16x2 + true, // BT SS 12.4 + true, // Local Adapter + true, // vGuest + true, // BT SS16.4 + true, // StarGuide 3 + true, // BT SS 4.2 + true, // Livewire LWRP Audio + true, // Quartz 1 + true, // BT SS 4.4 + true, // BT SRC8 III + true, // BT SRC16 + true, // Harlond + true, // ACU-1 Prophet + true, // LiveWire Multicast GPIO + true, // 360 AM16 + true, // LiveWire LWRP GPIO + true, // BT Sentinel 4 Web + true, // BT GPI-16 + true, // Modem Lines + false, // Software Authority + true, // SAS 16000 + true, // Ross NK/SCP + true, // BT ADMS 44.22 + true, // BT SS 4.1 MLR + true, // Modbus + true, // Kernel GPIO + true, // WheatNet SLIO + true, // WheatNet LIO + true, // BT Universal 4.1 MLR>>Web + true, // BT SS 2.1 + true // GVC 7000 + }; + RDMatrix::RDMatrix(const QString &station,int matrix) { QString sql; @@ -886,6 +935,12 @@ int RDMatrix::defaultControlValue(RDMatrix::Type type, } +bool RDMatrix::endpointsAreEditable(RDMatrix::Type type) +{ + return __mx_endpoints_are_editable_values[type]; +} + + QString RDMatrix::GetEndpointName(int pointnum,const QString &table) const { QString sql=QString("select `NAME` from ")+table+" where "+ diff --git a/lib/rdmatrix.h b/lib/rdmatrix.h index 5681c87f..3a0cb2dc 100644 --- a/lib/rdmatrix.h +++ b/lib/rdmatrix.h @@ -116,6 +116,7 @@ class RDMatrix static bool controlActive(RDMatrix::Type type,RDMatrix::Control control); static int defaultControlValue(RDMatrix::Type type, RDMatrix::Control control); + static bool endpointsAreEditable(RDMatrix::Type type); private: QString GetEndpointName(int pointnum,const QString &table) const; diff --git a/rdadmin/list_endpoints.cpp b/rdadmin/list_endpoints.cpp index bdb671bc..1c9ee555 100644 --- a/rdadmin/list_endpoints.cpp +++ b/rdadmin/list_endpoints.cpp @@ -64,8 +64,10 @@ ListEndpoints::ListEndpoints(RDMatrix *matrix,RDMatrix::Endpoint endpoint, list_type_label=new QLabel(list_table,this); list_type_label->setFont(labelFont()); list_type_label->setGeometry(14,5,85,19); - connect(list_list_view,SIGNAL(doubleClicked(const QModelIndex &)), - this,SLOT(doubleClickedData(const QModelIndex &))); + if(RDMatrix::endpointsAreEditable(list_matrix->type())) { + connect(list_list_view,SIGNAL(doubleClicked(const QModelIndex &)), + this,SLOT(doubleClickedData(const QModelIndex &))); + } connect(list_list_model,SIGNAL(modelReset()), list_list_view,SLOT(resizeColumnsToContents())); list_list_view->resizeColumnsToContents(); @@ -77,7 +79,8 @@ ListEndpoints::ListEndpoints(RDMatrix *matrix,RDMatrix::Endpoint endpoint, list_edit_button->setFont(buttonFont()); list_edit_button->setText(tr("Edit")); connect(list_edit_button,SIGNAL(clicked()),this,SLOT(editData())); - list_edit_button->setDisabled(list_readonly); + list_edit_button-> + setEnabled(RDMatrix::endpointsAreEditable(list_matrix->type())); // // Cancel Button diff --git a/rdadmin/list_endpoints.h b/rdadmin/list_endpoints.h index 886d2418..ba87941f 100644 --- a/rdadmin/list_endpoints.h +++ b/rdadmin/list_endpoints.h @@ -56,7 +56,7 @@ class ListEndpoints : public RDDialog QPushButton *list_close_button; int list_size; QString list_table; - bool list_readonly; + // bool list_readonly; };