2022-10-06 Fred Gleason <fredg@paravelsystems.com>

* Changed the type of the 'MATRICES.PASSWORD` field in the
	database to 'text'.
	* Changed the type of the 'MATRICES.PASSWORD_2` field in the
	database to 'text'.
	* Applied Base64 encoding to the 'MATRICES.PASSWORD' field in
	the database.
	* Applied Base64 encoding to the 'MATRICES.PASSWORD_2' field in
	the database.
	* Incremented the database version to 362.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2022-10-06 18:07:40 -04:00
parent f212c99a83
commit 844e10e1b6
8 changed files with 138 additions and 12 deletions

View File

@@ -24,7 +24,7 @@
/*
* Current Database Version
*/
#define RD_VERSION_DATABASE 361
#define RD_VERSION_DATABASE 362
#endif // DBVERSION_H

View File

@@ -459,10 +459,10 @@ QString RDMatrix::password(RDMatrix::Role role) const
{
switch(role) {
case RDMatrix::Primary:
return GetRow("PASSWORD").toString();
return QByteArray::fromBase64(GetRow("PASSWORD").toString().toUtf8());
case RDMatrix::Backup:
return GetRow("PASSWORD_2").toString();
return QByteArray::fromBase64(GetRow("PASSWORD_2").toString().toUtf8());
}
return QString();
}
@@ -472,10 +472,10 @@ void RDMatrix::setPassword(RDMatrix::Role role,const QString &passwd) const
{
switch(role) {
case RDMatrix::Primary:
SetRow("PASSWORD",passwd);
SetRow("PASSWORD",passwd.toUtf8().toBase64());
case RDMatrix::Backup:
SetRow("PASSWORD_2",passwd);
SetRow("PASSWORD_2",passwd.toUtf8().toBase64());
}
}
@@ -985,6 +985,26 @@ void RDMatrix::SetRow(const QString &param,const QString &value) const
}
void RDMatrix::SetRow(const QString &param,const QByteArray &value) const
{
QString sql;
if(value.size()==0) {
sql=QString("update `MATRICES` set `")+
param+"`=NULL where "+
"`STATION_NAME`='"+RDEscapeString(mx_station)+"' && "+
QString::asprintf("`MATRIX`=%d",mx_number);
}
else {
sql=QString("update `MATRICES` set `")+
param+"`='"+RDEscapeString(value)+"' where "+
"`STATION_NAME`='"+RDEscapeString(mx_station)+"' && "+
QString::asprintf("`MATRIX`=%d",mx_number);
}
RDSqlQuery::apply(sql);
}
void RDMatrix::SetRow(const QString &param,int value) const
{
QString sql;

View File

@@ -2,7 +2,7 @@
//
// Abstract a Rivendell Switcher Matrix
//
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@@ -21,9 +21,8 @@
#ifndef RDMATRIX_H
#define RDMATRIX_H
#include <qsqldatabase.h>
#include <qdatetime.h>
#include <qhostaddress.h>
#include <QDateTime>
#include <QHostAddress>
class RDMatrix
{
@@ -122,6 +121,7 @@ class RDMatrix
QString GetEndpointName(int pointnum,const QString &table) const;
QVariant GetRow(const QString &param) const;
void SetRow(const QString &param,const QString &value) const;
void SetRow(const QString &param,const QByteArray &value) const;
void SetRow(const QString &param,int value) const;
void SetRow(const QString &param,unsigned value) const;
int mx_id;