diff --git a/ChangeLog b/ChangeLog index 405950d8..40368088 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17023,3 +17023,6 @@ * Implemented the '--check' command in rddbmgr(8). 2018-06-08 Fred Gleason * Added an rddbmgr(8) man page. +2018-06-08 Fred Gleason + * Removed rddbcheck(8). + * Removed rdrevert(8). diff --git a/configure.ac b/configure.ac index 8e8bed2f..ff621e19 100644 --- a/configure.ac +++ b/configure.ac @@ -510,7 +510,6 @@ AC_CONFIG_FILES([rivendell.spec \ utils/rdclilogedit/Makefile \ utils/rdcollect/Makefile \ utils/rdconvert/Makefile \ - utils/rddbcheck/Makefile \ utils/rddbmgr/Makefile \ utils/rddelete/Makefile \ utils/rddgimport/Makefile \ @@ -524,7 +523,6 @@ AC_CONFIG_FILES([rivendell.spec \ utils/rdpopup/Makefile \ utils/rdpurgecasts/Makefile \ utils/rdrender/Makefile \ - utils/rdrevert/Makefile \ utils/rdsoftkeys/Makefile \ utils/rmlsend/Makefile \ utils/sas_shim/Makefile \ diff --git a/docs/manpages/Makefile.am b/docs/manpages/Makefile.am index 529be382..f822221f 100644 --- a/docs/manpages/Makefile.am +++ b/docs/manpages/Makefile.am @@ -33,32 +33,26 @@ all-local: rdclilogedit.1\ rdconvert.1\ - rddbcheck.8\ rddbmgr.8\ rdexport.1\ rdimport.1\ rdmarkerset.8\ rdrender.1\ - rdrevert.8\ rmlsend.1 man_MANS = rdclilogedit.1\ rdconvert.1\ - rddbcheck.8\ rddbmgr.8\ rdexport.1\ rdimport.1\ rdmarkerset.8\ rdrender.1\ - rdrevert.8\ rmlsend.1 EXTRA_DIST = rdclilogedit.1\ rdclilogedit.xml\ rdconvert.1\ rdconvert.xml\ - rddbcheck.8\ - rddbcheck.xml\ rddbmgr.8\ rddbmgr.xml\ rdexport.1\ @@ -69,8 +63,6 @@ EXTRA_DIST = rdclilogedit.1\ rdmarkerset.xml\ rdrender.1\ rdrender.xml\ - rdrevert.8\ - rdrevert.xml\ rmlsend.1\ rmlsend.xml diff --git a/docs/manpages/rddbcheck.xml b/docs/manpages/rddbcheck.xml deleted file mode 100644 index 3a1e8e96..00000000 --- a/docs/manpages/rddbcheck.xml +++ /dev/null @@ -1,210 +0,0 @@ - - - - - rddbcheck - 8 - March 2017 - Linux Audio Manual - - - rddbcheck - Tool for checking and repairing Rivendell databases - - - - - Fred - Gleason - fredg@paravelsystems.com - - Application Author - - - - - - - rddbcheck - OPTIONS - - - - - Description - - rddbcheck8 is a command-line - tool for checking the consistency of a Rivendell database and (perhaps) - repairing any inconsistencies found. When invoked without any options, - rddbcheck8 will run a set of - consistency checks (with the exception of the check of the SHA-1 hashes), - report any problems found and offer to repair the problem. To force a - SHA-1 hash check as well, see the option below. - - - - Consistency Check Options - - - - dir-name - - - - Move any "orphaned" audio files found to the - dir-name directory. - - - - - - - - - - - Automatically answer all interactive prompts with - No. - - - - - - - grp-name - - - - Move carts with missing/invalid GROUP information to the - grp-name group. - - - - - - - target - - - - Generate SHA-1 hashes from the specified files in the audio store - and validate them against the values stored in the database. This - is an inherently expensive operation that may require a - significant amount of time to complete as each audio - file to be checked must be opened and read in its entirety. - - - The target value can be one of the - following: - - - - - Cart number --e.g. 123456 - - - - Check hashs for all cuts within the specified cart. - - - - - - Cart/cut specification --e.g. 123456_001 - - - - Check the hash for the specified cut. - - - - - - ALL - - - - Check hashes for all cuts in the audio store. - - - - - - - - - - user-name - - - - Use the user-name Rivendell user. - Default value is user. - - - - - - - - - - - Automatically answer all interactive prompts with - Yes. - - - - - - Audio Recovery Options - - - - dir-name - - - - Scan the files in the directory dir-name - and copy/rename them into the Rivendell audio store if their SHA-1 - hash matches that for one or more Rivendell cuts. - - - - - - - - - - - When given along with , move the - audio data to the Rivendell audio store rather than copying it - --i.e. copy the audio data, then delete the original. - - - - - - - - - See Also - - - rdmarkerset8 - - , - - rdrevert8 - - - - - - - diff --git a/docs/manpages/rdrevert.xml b/docs/manpages/rdrevert.xml deleted file mode 100644 index b77ee2b4..00000000 --- a/docs/manpages/rdrevert.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - rdrevert - 8 - March 2016 - Linux Audio Manual - - - rdrevert - Revert a Rivendell database to a previous schema version - - - - - Fred - Gleason - fredg@paravelsystems.com - - Application Author - - - - - - - rdrevert - OPTIONS - --set-schema=schema - --set-version=version - - - - - Description - - rdrevert8 can be used to revert - the schema of a Rivendell database to an earlier version, specified as - either a Rivendell version string or an absolute schema version number. - If no arguments are given, rdrevert8 - will print the current database schema version to standard output and - then exit. - - - - Options - - - - schema - - - - Set the version number of the schema to which to revert. - rdrevert8 can revert back - up to schema version 242 (v2.10.0) inclusive. Attempting to - revert to an earlier schema than 242 will generate an - unsupported schema error. - - - - - - - version - - - - Determine the schema to which to revert on the basis of the - specified Rivendell version --e.g. 2.10.3. - - - - - - - - - diff --git a/rivendell.spec.in b/rivendell.spec.in index 50789305..3de63187 100644 --- a/rivendell.spec.in +++ b/rivendell.spec.in @@ -294,10 +294,9 @@ rm -rf $RPM_BUILD_ROOT @LOCAL_PREFIX@/bin/rdrender %attr(4755,root,root)@LOCAL_PREFIX@/bin/ripcd @LOCAL_PREFIX@/sbin/sas_shim -@LOCAL_PREFIX@/sbin/rddbcheck @LOCAL_PREFIX@/sbin/rdmarkerset @LOCAL_PREFIX@/sbin/rdcleandirs -@LOCAL_PREFIX@/sbin/rdrevert +@LOCAL_PREFIX@/sbin/rddbmgr @LOCAL_PREFIX@/share/rivendell/* /etc/init.d/rdrepld @LOCAL_PREFIX@/share/icons/hicolor/16x16/apps/rivendell.png @@ -409,9 +408,8 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/rdimport.1.gz %{_mandir}/man1/rdrender.1.gz %{_mandir}/man1/rmlsend.1.gz -%{_mandir}/man8/rddbcheck.8.gz +%{_mandir}/man8/rddbmgr.8.gz %{_mandir}/man8/rdmarkerset.8.gz -%{_mandir}/man8/rdrevert.8.gz @DOC_PATH@/* diff --git a/utils/Makefile.am b/utils/Makefile.am index bdc2a4fa..fa7e6978 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -24,7 +24,6 @@ if ALSA_RD_AM ALSACONFIG_RD_OPT = rdalsaconfig endif SUBDIRS = $(ALSACONFIG_RD_OPT)\ - rddbcheck\ rddgimport\ rdcheckcuts\ rdchunk\ @@ -44,7 +43,6 @@ SUBDIRS = $(ALSACONFIG_RD_OPT)\ rdpopup\ rdpurgecasts\ rdrender\ - rdrevert\ rdsoftkeys\ rmlsend\ sas_shim diff --git a/utils/rddbcheck/Makefile.am b/utils/rddbcheck/Makefile.am deleted file mode 100644 index f3824902..00000000 --- a/utils/rddbcheck/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -## automake.am -## -## Automake.am for rivendell/utils/rddbcheck -## -## (C) Copyright 2002-2006,2016 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 -## published by the Free Software Foundation. -## -## 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 this program; if not, write to the Free Software -## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -## -## Use automake to process this into a Makefile.in - -AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -DQTDIR=\"@QT_DIR@\" @QT_CXXFLAGS@ -I$(top_srcdir)/lib -LIBS = @QT_LIBS@ -L$(top_srcdir)/lib -MOC = @QT_MOC@ - -# The dependency for qt's Meta Object Compiler (moc) -moc_%.cpp: %.h - $(MOC) $< -o $@ - -sbin_PROGRAMS = rddbcheck - -dist_rddbcheck_SOURCES = rddbcheck.cpp rddbcheck.h - -rddbcheck_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ - -EXTRA_DIST = - -CLEANFILES = *~\ - *.idb\ - *ilk\ - *.obj\ - *.pdb\ - *.qm\ - moc_* - -MAINTAINERCLEANFILES = *~\ - Makefile.in\ - moc_* diff --git a/utils/rddbcheck/rddbcheck.cpp b/utils/rddbcheck/rddbcheck.cpp deleted file mode 100644 index 17a7430c..00000000 --- a/utils/rddbcheck/rddbcheck.cpp +++ /dev/null @@ -1,1056 +0,0 @@ -// rddbcheck.cpp -// -// A Database Check/Repair Tool for Rivendell. -// -// (C) Copyright 2002-2006,2016-2017 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 -// published by the Free Software Foundation. -// -// 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 this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// -// MAINTAINER'S NOTE -// Be sure to use QSqlQuery here, *not* RDSqlQuery, otherwise the -// DB connection will be reset when we detect an error! -// - -MainObject::MainObject(QObject *parent) - :QObject(parent) -{ - bool skip_db_check=false; - unsigned schema=0; - - check_yes=false; - check_no=false; - QString username="user"; - relink_audio=""; - relink_audio_move=false; - - // - // Read Command Options - // - RDCmdSwitch *cmd= - new RDCmdSwitch(qApp->argc(),qApp->argv(),"rddbcheck",RDDBCHECK_USAGE); - for(unsigned i=0;ikeys();i++) { - if(cmd->key(i)=="--skip-db-check") { - skip_db_check=true; - } - if(cmd->key(i)=="--user") { - username=cmd->value(i); - } - if(cmd->key(i)=="--yes") { - check_yes=true; - } - if(cmd->key(i)=="--no") { - check_no=true; - } - if(cmd->key(i)=="--orphan-group") { - orphan_group_name=cmd->value(i); - } - if(cmd->key(i)=="--dump-cuts-dir") { - dump_cuts_dir=cmd->value(i); - } - if(cmd->key(i)=="--relink-audio") { - relink_audio=cmd->value(i); - } - if(cmd->key(i)=="--relink-audio-move") { - relink_audio_move=true; - } - if(cmd->key(i)=="--rehash") { - rehash=cmd->value(i); - } - } - if(check_yes&&check_no) { - fprintf(stderr,"rddbcheck: '--yes' and '--no' are mutually exclusive\n"); - exit(256); - } - - // - // Check for Root Perms - // - if(geteuid()!=0) { - fprintf(stderr,"rddbcheck: must be user \"root\"\n"); - exit(256); - } - - // - // Check for dump cuts directory - // - if(!dump_cuts_dir.isEmpty()) { - QFileInfo file(dump_cuts_dir); - if(!file.exists()) { - fprintf(stderr,"rddbcheck: directory \"%s\" does not exist.\n", - (const char *)dump_cuts_dir); - exit(256); - } - if(!file.isDir()) { - fprintf(stderr,"rddbcheck: \"%s\" is not a directory.\n", - (const char *)dump_cuts_dir); - exit(256); - } - if(!file.isWritable()) { - fprintf(stderr,"rddbcheck: \"%s\" is not writable.\n", - (const char *)dump_cuts_dir); - exit(256); - } - } - - // - // Read Configuration - // - rdconfig=new RDConfig(); - rdconfig->load(); - rdconfig->setModuleName("rddbcheck"); - - // - // Open Database - // - QString err (tr("rddbcheck: ")); - QSqlDatabase *db=RDInitDb(&schema,&err); - if(!db) { - fprintf(stderr,err.ascii()); - delete cmd; - exit(256); - } - if((schema!=RD_VERSION_DATABASE)&&(!skip_db_check)) { - fprintf(stderr, - "rddbcheck: database version mismatch, should be %u, is %u\n", - RD_VERSION_DATABASE,schema); - exit(256); - } - - // - // Validate Station - // - check_station=new RDStation(rdconfig->stationName()); - if(!check_station->exists()) { - fprintf(stderr,"rddbcheck: no such host [\"%s\"]\n", - (const char *)rdconfig->stationName()); - } - - // - // Validate User - // - check_user=new RDUser(username); - if(!check_user->exists()) { - fprintf(stderr,"rddbcheck: no such user [\"%s\"]\n",(const char *)username); - } - - if(!orphan_group_name.isEmpty()) { - QString sql=QString().sprintf("select NAME from GROUPS where NAME=\"%s\"", - (const char *)orphan_group_name); - QSqlQuery *q=new QSqlQuery(sql); - if(!q->first()) { - fprintf(stderr,"rddbcheck: invalid group \"%s\"\n", - (const char *)orphan_group_name); - delete q; - exit(256); - } - delete q; - } - - // - // Recover Audio - // - if(!relink_audio.isEmpty()) { - RelinkAudio(relink_audio); - exit(0); - } - - // - // Check for Orphaned Voice Tracks - // - printf("Checking voice tracks...\n"); - CheckOrphanedTracks(); - printf("done.\n\n"); - - // - // Check RDLogManager Consistency - // - printf("Checking RDLogManager events...\n"); - CheckEvents(); - printf("done.\n\n"); - printf("Checking RDLogManager clocks...\n"); - CheckClocks(); - printf("done.\n\n"); - - // - // Check for orphaned tables - // - printf("Checking for orphaned tables...\n"); - CheckOrphanedTables(); - printf("done.\n\n"); - - // - // Check for stale reservations - // - printf("Checking for stale cart reservations...\n"); - CheckPendingCarts(); - printf("done.\n\n"); - - // - // Check for orphaned carts - // - printf("Checking for orphaned carts...\n"); - CheckOrphanedCarts(); - printf("done.\n\n"); - - // - // Check for orphaned cuts - // - printf("Checking for orphaned cuts...\n"); - CheckOrphanedCuts(); - printf("done.\n\n"); - - // - // Check Cart->Cut Counts - // - printf("Checking cart->cuts counters...\n"); - CheckCutCounts(); - printf("done.\n\n"); - - // - // Check Orphaned Audio - // - printf("Checking for orphaned audio...\n"); - CheckOrphanedAudio(); - printf("done.\n\n"); - - // - // Validating Audio Lengths - // - printf("Validating audio lengths (this may take some time)...\n"); - ValidateAudioLengths(); - printf("done.\n\n"); - - // - // Rehash - // - if(!rehash.isEmpty()) { - printf("Checking hashes...\n"); - Rehash(rehash); - printf("done.\n\n"); - } - - exit(0); -} - - -void MainObject::CheckOrphanedTracks() -{ - QString logname; - QString sql="select NUMBER,TITLE,OWNER from CART where OWNER!=\"\""; - QSqlQuery *q=new QSqlQuery(sql); - QSqlQuery *q1; - - while(q->next()) { - logname=q->value(2).toString()+"_LOG"; - logname.replace(" ","_"); - sql=QString().sprintf("select ID from `%s` where CART_NUMBER=%u", - (const char *)logname,q->value(0).toUInt()); - q1=new QSqlQuery(sql); - if(!q1->first()) { - printf(" Found orphaned track %u - \"%s\". Delete? (y/N) ", - q->value(0).toUInt(),(const char *)q->value(1).toString()); - fflush(NULL); - if(UserResponse()) { - RDCart *cart=new RDCart(q->value(0).toUInt()); - cart->remove(check_station,check_user,rdconfig); - delete cart; - RDLog *log=new RDLog(q->value(2).toString()); - if(log->exists()) { - log->updateTracks(); - } - delete log; - } - } - delete q1; - } - delete q; -} - - -void MainObject::CheckClocks() -{ - QString sql; - QSqlQuery *q; - QSqlQuery *q1; - QSqlQuery *q2; - QSqlQuery *q3; - QString eventname; - - sql="select NAME from CLOCKS"; - q=new QSqlQuery(sql); - while(q->next()) { - // - // Check the CLK Table - // - sql=QString("select EVENT_NAME,ID from ")+ - RDClock::tableName(q->value(0).toString()); - q1=new QSqlQuery(sql); - if(q1->isActive()) { - // - // Check the clock -> event linkage - // - while(q1->next()) { - sql=QString().sprintf("select NAME from EVENTS where NAME=\"%s\"", - (const char *)q1->value(0).toString()); - q2=new QSqlQuery(sql); - if(q2->first()) { - if(q1->value(0)!=q2->value(0)) { // Make sure the cases match! - printf(" Clock %s's linkage to event %s is broken -- fix (y/N)? ", - (const char *)q->value(0).toString(), - (const char *)q2->value(0).toString()); - fflush(NULL); - if(UserResponse()) { - sql=QString("update ")+ - RDClock::tableName(q->value(0).toString())+ - " set EVENT_NAME=\""+RDEscapeString(q2->value(0).toString())+ - "\""+QString().sprintf(" where ID=%d",q1->value(1).toInt()); - q3=new QSqlQuery(sql); - delete q3; - } - } - } - delete q2; - } - } - else { - printf(" Clock %s is missing the CLK table -- fix (y/N)? ", - (const char *)q->value(0).toString()); - fflush(NULL); - if(UserResponse()) { - sql=RDCreateClockTableSql(RDClock::tableName(q->value(0).toString()), - rdconfig); - q2=new QSqlQuery(sql); - delete q2; - } - } - delete q1; - } - delete q; -} - - -void MainObject::CheckEvents() -{ - QString sql; - QSqlQuery *q; - QSqlQuery *q1; - QSqlQuery *q2; - QString eventname; - - sql="select NAME from EVENTS"; - q=new QSqlQuery(sql); - while(q->next()) { - eventname=q->value(0).toString(); - eventname.replace(" ","_"); - - // - // Check the PRE Table - // - sql=QString().sprintf ("select ID from %s_PRE",(const char *)eventname); - q1=new QSqlQuery(sql); - if(q1->size()<0) { - printf(" Event %s is missing the PRE table -- fix (y/N)? ", - (const char *)q->value(0).toString()); - fflush(NULL); - if(UserResponse()) { - sql=RDCreateLogTableSql(eventname+"_PRE",rdconfig); - q2=new QSqlQuery(sql); - delete q2; - } - } - delete q1; - - // - // Check the POST Table - // - sql=QString().sprintf ("select ID from %s_POST",(const char *)eventname); - q1=new QSqlQuery(sql); - if(!q1->isActive()) { - printf(" Event %s is missing the POST table -- fix (y/N)? ", - (const char *)q->value(0).toString()); - fflush(NULL); - if(UserResponse()) { - sql=RDCreateLogTableSql(eventname+"_POST",rdconfig); - q2=new QSqlQuery(sql); - delete q2; - } - } - delete q1; - } - delete q; -} - - -void MainObject::CheckOrphanedTables() -{ - QSqlQuery *table_q; - QSqlQuery *q; - QString sql; - - // - // Generate Table Query - // - sql="show tables"; - table_q=new QSqlQuery(sql); - - // - // Look for orphaned clocks - // - sql="select NAME from CLOCKS"; - q=new QSqlQuery(sql); - CleanTables("CLK",table_q,q); - CleanTables("RULES",table_q,q); - delete q; - - // - // Look for orphaned events - // - sql="select NAME from EVENTS"; - q=new QSqlQuery(sql); - CleanTables("PRE",table_q,q); - CleanTables("POST",table_q,q); - delete q; - - // - // Look for orphaned logs - // - sql="select NAME from LOGS"; - q=new QSqlQuery(sql); - CleanTables("LOG",table_q,q); - CleanTables("STACK",table_q,q); - delete q; - - // - // Look for orphaned services - // - sql="select NAME from SERVICES"; - q=new QSqlQuery(sql); - CleanTables("SRT",table_q,q); - delete q; - - // - // Look for orphaned feeds - // - sql="select KEY_NAME from FEEDS"; - q=new QSqlQuery(sql); - CleanTables("FIELDS",table_q,q); - CleanTables("FLG",table_q,q); - delete q; - - // - // Look for stale and obsolete tables - // - CleanTables("IMP",table_q); - CleanTables("REC",table_q); - - - delete table_q; -} - - -void MainObject::CheckCutCounts() -{ - QString sql; - QSqlQuery *q; - QSqlQuery *q1; - - sql="select NUMBER,CUT_QUANTITY,TITLE from CART"; - q=new QSqlQuery(sql); - while(q->next()) { - sql=QString().sprintf("select CUT_NAME from CUTS \ - where (CART_NUMBER=%u)&&(LENGTH>0)", - q->value(0).toUInt()); - q1=new QSqlQuery(sql); - if(q1->size()!=q->value(1).toInt()) { - printf(" Cart %u [%s] has invalid cut count, fix (y/N)?", - q->value(0).toUInt(),(const char *)q->value(2).toString()); - if(UserResponse()) { - RDCart *cart=new RDCart(q->value(0).toUInt()); - cart->updateLength(); - cart->resetRotation(); - delete cart; - } - } - delete q1; - } - delete q; -} - - -void MainObject::CheckPendingCarts() -{ - QString sql; - QSqlQuery *q; - QDateTime now(QDate::currentDate(),QTime::currentTime()); - - sql=QString("select NUMBER from CART where ")+ - "(PENDING_STATION is not null)&&"+ - "(PENDING_DATETIME<\""+now.addDays(-1). - toString("yyyy-MM-dd hh:mm:ss")+"\")"; - q=new QSqlQuery(sql); - while(q->next()) { - printf(" Cart %06u has stale reservation, delete cart(y/N)?", - q->value(0).toUInt()); - if(UserResponse()) { - RDCart::removeCart(q->value(0).toUInt(),check_station,check_user, - rdconfig); - } - } - delete q; -} - - -void MainObject::CheckOrphanedCarts() -{ - QString sql; - QSqlQuery *q; - QSqlQuery *q1; - - sql="select CART.NUMBER,CART.TITLE from CART left join GROUPS \ - on CART.GROUP_NAME=GROUPS.NAME where GROUPS.NAME is null"; - q=new QSqlQuery(sql); - while(q->next()) { - printf(" Cart %06u [%s] has missing/invalid group.\n", - q->value(0).toUInt(),(const char *)q->value(1).toString()); - if(orphan_group_name.isEmpty()) { - printf(" Rerun rddbcheck with the --orphan-group= switch to fix.\n\n"); - } - else { - printf(" Assign to group \"%s\" (y/N)?",(const char *)orphan_group_name); - if(UserResponse()) { - sql=QString(). - sprintf("update CART set GROUP_NAME=\"%s\" where NUMBER=%u", - (const char *)RDEscapeString(orphan_group_name), - q->value(0).toUInt()); - q1=new QSqlQuery(sql); - delete q1; - } - printf("\n"); - } - } - delete q; -} - - -void MainObject::CheckOrphanedCuts() -{ - QString sql; - QSqlQuery *q; - QSqlQuery *q1; - QSqlQuery *q2; - QFileInfo *file=NULL; - - sql="select CUTS.CUT_NAME,CUTS.DESCRIPTION from CUTS left join CART \ - on CUTS.CART_NUMBER=CART.NUMBER where CART.NUMBER is null"; - q=new QSqlQuery(sql); - while(q->next()) { - printf(" Cut %s [%s] is orphaned.\n", - (const char *)q->value(0).toString(), - (const char *)q->value(1).toString()); - // - // Try to repair it - // - sql=QString().sprintf("select NUMBER from CART where NUMBER=%d", - q->value(0).toString().left(6).toUInt()); - q1=new QSqlQuery(sql); - if(q1->first()) { - printf(" Repair it (y/N)?"); - if(UserResponse()) { - // - // FIXME: Regen Cart Data - // - sql=QString(). - sprintf("update CUTS set CART_NUMBER=%u where CUT_NAME=\"%s\"", - q1->value(0).toUInt(), - (const char *)q->value(0).toString()); - q2=new QSqlQuery(sql); - delete q2; - delete q1; - printf("\n"); - continue; - } - } - printf("\n"); - delete q1; - - // - // Try to recover audio - // - file=new QFileInfo(RDCut::pathName(q->value(0).toString())); - if(!file->exists()) { - printf(" Clear it (y/N)?"); - if(UserResponse()) { - sql=QString().sprintf("delete from CUTS where CUT_NAME=\"%s\"", - (const char *)q->value(0).toString()); - q1=new QSqlQuery(sql); - delete q1; - } - } - else { - if(dump_cuts_dir.isEmpty()) { - printf(" Rerun rddbcheck with the --dump-cuts-dir= switch to fix.\n"); - } - else { - printf(" Clear it (y/N)?"); - if(UserResponse()) { - system("mv "+file->filePath()+" "+dump_cuts_dir+"/"); - sql=QString().sprintf("delete from CUTS where CUT_NAME=\"%s\"", - (const char *)q->value(0).toString()); - q1=new QSqlQuery(sql); - delete q1; - printf(" Saved audio in \"%s/%s\"\n",(const char *)dump_cuts_dir, - (const char *)file->fileName()); - } - } - } - printf("\n"); - delete file; - file=NULL; - } - delete q; -} - - -void MainObject::CheckOrphanedAudio() -{ - QDir dir(rdconfig->audioRoot()); - QStringList list=dir.entryList("??????_???.wav",QDir::Files); - for(unsigned i=0;ifirst()) { - printf(" File \"%s/%s\" is orphaned.\n", - (const char *)rdconfig->audioRoot(),(const char *)list[i]); - if(dump_cuts_dir.isEmpty()) { - printf( - " Rerun rddbcheck with the --dump-cuts-dir= switch to fix.\n\n"); - } - else { - printf(" Move to \"%s\" (y/N)? ",(const char *)dump_cuts_dir); - if(UserResponse()) { - system(QString().sprintf("mv %s/%s %s/", - (const char *)rdconfig->audioRoot(), - (const char *)list[i], - (const char *)dump_cuts_dir)); - printf(" Saved audio in \"%s/%s\"\n",(const char *)dump_cuts_dir, - (const char *)list[i]); - } - } - } - delete q; - } - } - } -} - - -void MainObject::ValidateAudioLengths() -{ - QString sql; - QSqlQuery *q; - RDWaveFile *wave=NULL; - - sql="select CUT_NAME,CART_NUMBER,LENGTH from CUTS order by CART_NUMBER"; - q=new QSqlQuery(sql); - while(q->next()) { - if(q->value(2).toInt()>0) { - wave=new RDWaveFile(RDCut::pathName(q->value(0).toString())); - if(wave->openWave()) { - if((int)wave->getExtTimeLength()<(q->value(2).toInt()-100)) { - SetCutLength(q->value(0).toString(),wave->getExtTimeLength()); - } - } - else { - SetCutLength(q->value(0).toString(),0); - } - delete wave; - } - } - delete q; -} - - -void MainObject::Rehash(const QString &arg) -{ - QString sql; - QSqlQuery *q; - unsigned cartnum; - bool ok=false; - - if(arg.lower()=="all") { - sql=QString("select NUMBER from CART where ")+ - QString().sprintf("TYPE=%d ",RDCart::Audio)+ - "order by NUMBER"; - q=new QSqlQuery(sql); - while(q->next()) { - RehashCart(q->value(0).toUInt()); - } - delete q; - return; - } - cartnum=arg.toUInt(&ok); - if(ok&&(cartnum>0)&&(cartnum<=RD_MAX_CART_NUMBER)) { - RehashCart(cartnum); - return; - } - RDCut *cut=new RDCut(arg); - if(cut->exists()) { - RehashCut(arg); - } - delete cut; -} - - -void MainObject::RehashCart(unsigned cartnum) -{ - RDCart *cart=new RDCart(cartnum); - if(cart->exists()) { - if(cart->type()==RDCart::Audio) { - QString sql=QString("select CUT_NAME from CUTS where ")+ - QString().sprintf("CART_NUMBER=%u ",cartnum)+ - "order by CUT_NAME"; - QSqlQuery *q=new QSqlQuery(sql); - while(q->next()) { - RehashCut(q->value(0).toString()); - } - delete q; - } - } - else { - printf(" Cart %06u does not exist.\n",cartnum); - } -} - - -void MainObject::RehashCut(const QString &cutnum) -{ - QString hash=RDSha1Hash(RDCut::pathName(cutnum),true); - if(hash.isEmpty()) { - printf(" Unable to generate hash for \"%s\"\n", - (const char *)RDCut::pathName(cutnum)); - } - else { - RDCut *cut=new RDCut(cutnum); - if(cut->exists()) { - if(cut->sha1Hash().isEmpty()) { - cut->setSha1Hash(hash); - } - else { - if(cut->sha1Hash()!=hash) { - RDCart *cart=new RDCart(RDCut::cartNumber(cutnum)); - printf(" Cut %d [%s] in cart %06u [%s] has inconsistent SHA1 hash. Fix? (y/N) ", - cut->cutNumber(), - (const char *)cut->description(), - cart->number(), - (const char *)cart->title()); - fflush(NULL); - if(UserResponse()) { - cut->setSha1Hash(hash); - } - delete cart; - } - } - } - else { - printf(" Cut \"%s\" does not exist.\n",(const char *)cutnum); - } - delete cut; - } -} - - -void MainObject::RelinkAudio(const QString &srcdir) -{ - QString sql; - RDSqlQuery *q; - - QDir dir(srcdir); - if(!dir.exists()) { - fprintf(stderr,"rddbcheck: --relink-audio directory does not exist\n"); - exit(256); - } - QStringList files=dir.entryList(QDir::Files|QDir::Readable|QDir::Hidden); - for(unsigned i=0;inext()) { - printf(" Recovering %06u/%03d [%s]...", - RDCut::cartNumber(q->value(0).toString()), - RDCut::cutNumber(q->value(0).toString()), - (const char *)q->value(1).toString()); - fflush(stdout); - if(relink_audio_move) { - unlink(RDCut::pathName(q->value(0).toString())); - if(link(filename,RDCut::pathName(q->value(0).toString()))<0) { - if(errno==EXDEV) { - if(firstdest.isEmpty()) { - if(CopyFile(RDCut::pathName(q->value(0).toString()),filename)) { - firstdest=RDCut::pathName(q->value(0).toString()); - } - else { - fprintf(stderr,"unable to copy file \"%s\"\n", - (const char *)filename); - delete_source=false; - } - } - else { - unlink(RDCut::pathName(q->value(0).toString())); - link(firstdest,RDCut::pathName(q->value(0).toString())); - } - } - else { - fprintf(stderr,"unable to move file \"%s\" [%s]\n", - (const char *)filename,strerror(errno)); - delete_source=false; - } - } - } - else { - if(firstdest.isEmpty()) { - if(CopyFile(RDCut::pathName(q->value(0).toString()),filename)) { - firstdest=RDCut::pathName(q->value(0).toString()); - } - else { - fprintf(stderr,"unable to copy file \"%s\"\n", - (const char *)filename); - } - } - else { - unlink(RDCut::pathName(q->value(0).toString())); - link(firstdest,RDCut::pathName(q->value(0).toString())); - } - } - printf(" done.\n"); - } - if(relink_audio_move&&delete_source) { - unlink(filename); - } - } -} - - -void MainObject::SetCutLength(const QString &cutname,int len) -{ - QString sql; - QSqlQuery *q; - RDCut *cut=new RDCut(cutname); - RDCart *cart=new RDCart(cut->cartNumber()); - - printf(" Cut %d [%s] in cart %06u [%s] has invalid length. Correct? (y/N) ", - cut->cutNumber(), - (const char *)cut->description(), - cart->number(), - (const char *)cart->title()); - fflush(NULL); - if(UserResponse()) { - fflush(NULL); - sql=QString().sprintf("update CUTS set START_POINT=0,END_POINT=%d,\ - FADEUP_POINT=-1,FADEDOWN_POINT=-1,\ - SEGUE_START_POINT=-1,SEGUE_END_POINT=-1,\ - TALK_START_POINT=-1,TALK_END_POINT=-1,\ - HOOK_START_POINT=-1,HOOK_END_POINT=-1,\ - PLAY_GAIN=0,LENGTH=%d \ - where CUT_NAME=\"%s\"", - len,len,(const char *)cutname); - q=new QSqlQuery(sql); - delete q; - cart->updateLength(); - cart->resetRotation(); - } - delete cart; - delete cut; -} - - -void MainObject::CleanTables(const QString &ext,QSqlQuery *table_q, - QSqlQuery *name_q) -{ - QString sql; - QSqlQuery *q1; - - table_q->seek(-1); - while(table_q->next()) { - if(!IsTableLinked(name_q,ext,table_q->value(0).toString())) { - printf(" Table %s is orphaned -- delete (y/N)? ", - (const char *)RDEscapeString(table_q->value(0).toString())); - fflush(NULL); - if(UserResponse()) { - sql=QString().sprintf("drop table %s", - (const char *)RDEscapeString(table_q->value(0).toString())); - q1=new QSqlQuery(sql); - delete q1; - } - } - } -} - - -void MainObject::CleanTables(const QString &ext,QSqlQuery *table_q) -{ - QString sql; - QSqlQuery *q1; - - table_q->seek(-1); - while(table_q->next()) { - if(table_q->value(0).toString().right(ext.length())==ext) { - printf(" Table %s is orphaned -- delete (y/N)? ", - (const char *)table_q->value(0).toString()); - fflush(NULL); - if(UserResponse()) { - sql=QString().sprintf("drop table %s", - (const char *)RDEscapeString(table_q->value(0).toString())); - q1=new QSqlQuery(sql); - delete q1; - } - } - } -} - - -bool MainObject::IsTableLinked(QSqlQuery *name_q,const QString &ext, - const QString &table) -{ - QString tablename; - - if(table.right(ext.length())!=ext) { - return true; - } - name_q->seek(-1); - while(name_q->next()) { - tablename=name_q->value(0).toString()+"_"+ext; - tablename.replace(" ","_"); - if(tablename==table) { - return true; - } - } - return false; -} - - -bool MainObject::CopyFile(const QString &destfile,const QString &srcfile) const -{ - int src_fd=-1; - struct stat src_stat; - int dest_fd=-1; - struct stat dest_stat; - int n; - int blksize; - char *data=NULL; - - if((src_fd=open(srcfile,O_RDONLY))<0) { - return false; - } - fstat(src_fd,&src_stat); - mode_t mask=umask(S_IRWXO); - if((dest_fd=open(destfile,O_WRONLY|O_CREAT|O_TRUNC, - S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP))<0) { - close(src_fd); - return false; - } - umask(mask); - fstat(dest_fd,&dest_stat); - blksize=src_stat.st_blksize; - if(dest_stat.st_blksize -// -// 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 -// published by the Free Software Foundation. -// -// 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 this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// - -#ifndef RDDBCHECK_H -#define RDDBCHECK_H - -#include - -#include -#include - -#include -#include -#include -#include - -#define RDDBCHECK_USAGE "[options]\n" - -// -// Global Variables -// -RDConfig *rdconfig; - -class MainObject : public QObject -{ - public: - MainObject(QObject *parent=0); - - private: - void CheckOrphanedTracks(); - void CheckClocks(); - void CheckEvents(); - void CheckOrphanedTables(); - void CheckCutCounts(); - void CheckPendingCarts(); - void CheckOrphanedCarts(); - void CheckOrphanedCuts(); - void CheckOrphanedAudio(); - void ValidateAudioLengths(); - void Rehash(const QString &arg); - void RehashCart(unsigned cartnum); - void RehashCut(const QString &cutnum); - void RelinkAudio(const QString &srcdir); - void SetCutLength(const QString &cutname,int len); - void CleanTables(const QString &ext,QSqlQuery *table_q,QSqlQuery *name_q); - void CleanTables(const QString &ext,QSqlQuery *table_q); - bool IsTableLinked(QSqlQuery *name_q,const QString &ext,const QString &table); - bool CopyFile(const QString &destfile,const QString &srcfile) const; - bool UserResponse(); - bool check_yes; - bool check_no; - QString orphan_group_name; - QString dump_cuts_dir; - QString rehash; - RDStation *check_station; - RDUser *check_user; - QString relink_audio; - bool relink_audio_move; -}; - - -#endif // RDDBCHECK_H diff --git a/utils/rdrevert/Makefile.am b/utils/rdrevert/Makefile.am deleted file mode 100644 index 5e093990..00000000 --- a/utils/rdrevert/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -## automake.am -## -## Automake.am for rivendell/utils/rdrevert -## -## (C) Copyright 2016 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 -## published by the Free Software Foundation. -## -## 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 this program; if not, write to the Free Software -## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -## -## Use automake to process this into a Makefile.in - -AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -DQTDIR=\"@QT_DIR@\" @QT_CXXFLAGS@ -I$(top_srcdir)/lib -LIBS = @QT_LIBS@ -L$(top_srcdir)/lib -MOC = @QT_MOC@ - -# The dependency for qt's Meta Object Compiler (moc) -moc_%.cpp: %.h - $(MOC) $< -o $@ - -sbin_PROGRAMS = rdrevert - -dist_rdrevert_SOURCES = rdrevert.cpp rdrevert.h - -rdrevert_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ - -CLEANFILES = *~\ - *.exe\ - *.idb\ - *ilk\ - *.obj\ - *.pdb\ - *.qm\ - moc_* - -MAINTAINERCLEANFILES = *~\ - *.tar.gz\ - aclocal.m4\ - configure\ - Makefile.in\ - moc_* diff --git a/utils/rdrevert/rdrevert.cpp b/utils/rdrevert/rdrevert.cpp deleted file mode 100644 index f09f744c..00000000 --- a/utils/rdrevert/rdrevert.cpp +++ /dev/null @@ -1,1549 +0,0 @@ -// rdrevert.cpp -// -// Revert the Rivendell database schema to an earlier version. -// -// (C) Copyright 2016-2018 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 -// published by the Free Software Foundation. -// -// 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 this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "rdrevert.h" - -MainObject::MainObject(QObject *parent) - :QObject(parent) -{ - bool ok=false; - int set_schema=0; - rev_use_deadzone=false; - - // - // Check for Root Permissions - // - if(geteuid()!=0) { - fprintf(stderr,"rdrevert: this program requires root permissions\n"); - exit(256); - } - - // - // Read Command Options - // - RDCmdSwitch *cmd= - new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdcollect",RDREVERT_USAGE); - for(unsigned i=0;ikeys();i++) { - if(cmd->key(i)=="--set-schema") { - set_schema=cmd->value(i).toInt(&ok); - if((!ok)||(set_schema<0)) { - fprintf(stderr,"rdrevert: invalid schema value\n"); - exit(256); - } - cmd->setProcessed(i,true); - } - if(cmd->key(i)=="--set-version") { - if((set_schema=MapSchema(cmd->value(i)))==0) { - fprintf(stderr,"rdrevert: invalid/unsupported Rivendell version\n"); - exit(256); - } - cmd->setProcessed(i,true); - } - } - if(!cmd->allProcessed()) { - fprintf(stderr,"rdrevert: unknown option\n"); - exit(256); - } - - // - // Load Local Configs - // - rev_config=new RDConfig(); - rev_config->load(); - rev_config->setModuleName("rdrevert"); - - // - // Open Database - // - rev_db=QSqlDatabase::addDatabase(rev_config->mysqlDriver()); - if(!rev_db) { - fprintf(stderr,"rdrevert: unable to connect to mysql server\n"); - exit(256); - } - rev_db->setDatabaseName(rev_config->mysqlDbname()); - rev_db->setUserName(rev_config->mysqlUsername()); - rev_db->setPassword(rev_config->mysqlPassword()); - rev_db->setHostName(rev_config->mysqlHostname()); - if(!rev_db->open()) { - fprintf(stderr,"rdrevert: unable to authenticate with mysql server\n"); - rev_db->removeDatabase(rev_config->mysqlDbname()); - exit(256); - } - - int start_schema=GetVersion(); - if(set_schema==0) { - printf("%d\n",start_schema); - exit(0); - } - if((set_schemastart_schema)) { - fprintf(stderr,"rdrevert: unsupported schema\n"); - exit(256); - } - if((start_schema>=246)&&(start_schema<=253)) { - rev_use_deadzone=true; - } - - while(start_schema>set_schema) { - Revert(start_schema--); - } - exit(0); -} - - -void MainObject::Revert(int schema) const -{ - switch(schema) { - case 243: - Revert243(); - break; - - case 244: - Revert244(); - break; - - case 245: - Revert245(); - break; - - case 246: - Revert246(); - break; - - case 247: - Revert247(); - break; - - case 248: - Revert248(); - break; - - case 249: - Revert249(); - break; - - case 250: - Revert250(); - break; - - case 251: - Revert251(); - break; - - case 252: - Revert252(); - break; - - case 253: - Revert253(); - break; - - case 254: - Revert254(); - break; - - case 255: - Revert255(); - break; - - case 256: - Revert256(); - break; - - case 257: - Revert257(); - break; - - case 258: - Revert258(); - break; - - case 259: - Revert259(); - break; - - case 260: - Revert260(); - break; - - case 261: - Revert261(); - break; - - case 262: - Revert262(); - break; - - case 263: - Revert263(); - break; - - case 264: - Revert264(); - break; - - case 265: - Revert265(); - break; - - case 266: - Revert266(); - break; - - case 267: - Revert267(); - break; - - case 268: - Revert268(); - break; - - case 269: - Revert269(); - break; - - case 270: - Revert270(); - break; - - case 271: - Revert271(); - break; - - case 272: - Revert272(); - break; - - case 273: - Revert273(); - break; - - case 274: - Revert274(); - break; - - case 275: - Revert275(); - break; - - case 276: - Revert276(); - break; - - case 277: - Revert277(); - break; - - case 278: - Revert278(); - break; - - case 279: - Revert279(); - break; - - case 280: - Revert280(); - break; - - case 281: - Revert281(); - break; - - case 282: - Revert282(); - break; - - case 283: - Revert283(); - break; - - case 284: - Revert284(); - break; - - case 285: - Revert285(); - break; - - case 286: - Revert286(); - break; - } -} - - -void MainObject::Revert243() const -{ - QString sql; - QSqlQuery *q; - - sql=QString("alter table STATIONS drop column HAVE_MP4_DECODE"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(242); -} - - -void MainObject::Revert244() const -{ - QString sql; - QSqlQuery *q; - - sql=QString("alter table JACK_CLIENTS modify column COMMAND_LINE ")+ - "char(255) not null"; - q=new QSqlQuery(sql); - delete q; - - SetVersion(243); -} - - -void MainObject::Revert245() const -{ - QString sql; - QSqlQuery *q; - - sql=QString("alter table RDLIBRARY drop column READ_ISRC"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(244); -} - - -void MainObject::Revert246() const -{ - if(rev_use_deadzone) { - } - SetVersion(245); -} - - -void MainObject::Revert247() const -{ - if(rev_use_deadzone) { - } - SetVersion(246); -} - - -void MainObject::Revert248() const -{ - if(rev_use_deadzone) { - } - SetVersion(247); -} - - -void MainObject::Revert249() const -{ - if(rev_use_deadzone) { - } - SetVersion(248); -} - - -void MainObject::Revert250() const -{ - if(rev_use_deadzone) { - } - SetVersion(249); -} - - -void MainObject::Revert251() const -{ - QString sql; - QSqlQuery *q; - QSqlQuery *q1; - QSqlQuery *q2; - - if(rev_use_deadzone) { - sql=QString("select NAME from CLOCKS"); - q=new QSqlQuery(sql); - while(q->next()) { - sql=RDCreateClockTableSql(RDClock::tableName(q->value(0).toString()), - rev_config); - q1=new QSqlQuery(sql); - delete q1; - sql=QString("select EVENT_NAME,START_TIME,LENGTH from CLOCK_METADATA ")+ - "where CLOCK_NAME=\""+RDEscapeString(q->value(0).toString())+"\" "+ - "order by START_TIME"; - q1=new QSqlQuery(sql); - while(q1->next()) { - sql=QString("insert into `")+ - RDClock::tableName(q->value(0).toString())+"` set "+ - "EVENT_NAME=\""+RDEscapeString(q1->value(0).toString())+"\","+ - QString().sprintf("START_TIME=%d,",q1->value(1).toInt())+ - QString().sprintf("LENGTH=%d",q1->value(2).toInt()); - q2=new QSqlQuery(sql); - delete q2; - } - delete q1; - } - delete q; - } - SetVersion(250); -} - - -void MainObject::Revert252() const -{ - QString sql; - QSqlQuery *q; - QSqlQuery *q1; - QSqlQuery *q2; - - if(rev_use_deadzone) { - sql=QString("select NAME from EVENTS"); - q=new QSqlQuery(sql); - while(q->next()) { - RDCreateLogTable(RDEvent::preimportTableName(q->value(0).toString()), - rev_config); - sql=QString("select COUNT,TYPE,TRANS_TYPE,CART_NUMBER,TEXT ")+ - "from EVENT_METADATA where "+ - "(EVENT_NAME=\""+RDEscapeString(q->value(0).toString())+"\")&&"+ - "(PLACE=0)"; - q1=new QSqlQuery(sql); - while(q1->next()) { - sql=QString("insert into `")+ - RDEvent::preimportTableName(q->value(0).toString())+"` set "+ - QString().sprintf("COUNT=%d,",q1->value(0).toInt())+ - QString().sprintf("TYPE=%d,",q1->value(1).toInt())+ - QString().sprintf("TRANS_TYPE=%d,",q1->value(2).toInt())+ - QString().sprintf("CART_NUMBER=%u,",q1->value(3).toUInt())+ - "COMMENT=\""+RDEscapeString(q1->value(4).toString())+"\""; - q2=new QSqlQuery(sql); - delete q2; - } - delete q1; - - RDCreateLogTable(RDEvent::postimportTableName(q->value(0).toString()), - rev_config); - sql=QString("select COUNT,TYPE,TRANS_TYPE,CART_NUMBER,TEXT ")+ - "from EVENT_METADATA where "+ - "(EVENT_NAME=\""+RDEscapeString(q->value(0).toString())+"\")&&"+ - "(PLACE=1)"; - q1=new QSqlQuery(sql); - while(q1->next()) { - sql=QString("insert into `")+ - RDEvent::postimportTableName(q->value(0).toString())+"` set "+ - QString().sprintf("COUNT=%d,",q1->value(0).toInt())+ - QString().sprintf("TYPE=%d,",q1->value(1).toInt())+ - QString().sprintf("TRANS_TYPE=%d,",q1->value(2).toInt())+ - QString().sprintf("CART_NUMBER=%u,",q1->value(3).toUInt())+ - "COMMENT=\""+RDEscapeString(q1->value(4).toString())+"\""; - q2=new QSqlQuery(sql); - delete q2; - } - delete q1; - } - delete q; - } - sql=QString("drop table EVENT_METADATA"); - q=new QSqlQuery(sql); - delete q; - SetVersion(251); -} - - -void MainObject::Revert253() const -{ - QString sql; - QSqlQuery *q; - - if(rev_use_deadzone) { - sql=QString("alter table CART add column PLAY_ORDER int unsigned ")+ - "after LAST_CUT_PLAYED"; - q=new QSqlQuery(sql); - delete q; - - sql=QString("alter table CART drop column USE_DAYPARTING"); - q=new QSqlQuery(sql); - delete q; - } - - SetVersion(252); -} - - -void MainObject::Revert254() const -{ - QString sql; - QSqlQuery *q; - - sql=QString("alter table CUTS drop column PLAY_ORDER"); - q=new QSqlQuery(sql); - delete q; - - sql=QString("alter table CART drop column USE_WEIGHTING"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(253); -} - - -void MainObject::Revert255() const -{ - QString sql; - QSqlQuery *q; - QSqlQuery *q1; - - sql=QString("select NAME from SERVICES"); - q=new QSqlQuery(sql); - while(q->next()) { - sql=QString("alter table `")+RDSvc::svcTableName(q->value(0).toString())+ - "` drop column DESCRIPTION"; - q1=new QSqlQuery(sql); - delete q1; - - sql=QString("alter table `")+RDSvc::svcTableName(q->value(0).toString())+ - "` drop column OUTCUE"; - q1=new QSqlQuery(sql); - delete q1; - } - delete q; - - SetVersion(254); -} - - -void MainObject::Revert256() const -{ - QString sql; - QSqlQuery *q; - - sql=QString("drop table CUT_EVENTS"); - q=new QSqlQuery(sql); - delete q; - - sql=QString("drop table DECK_EVENTS"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(255); -} - - -void MainObject::Revert257() const -{ - QString sql; - QSqlQuery *q; - - sql=QString("alter table LOGS modify column LINK_DATETIME datetime not null"); - q=new QSqlQuery(sql); - delete q; - - sql=QString("alter table LOGS modify column START_DATE date not null"); - q=new QSqlQuery(sql); - delete q; - - sql=QString("alter table LOGS modify column END_DATE date not null"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(256); -} - - -void MainObject::Revert258() const -{ - QString sql; - QSqlQuery *q; - QSqlQuery *q1; - - sql=QString("select NAME from LOGS"); - q=new QSqlQuery(sql); - while(q->next()) { - sql=QString("alter table ")+ - "`"+RDLog::tableName(q->value(0).toString())+"` "+ - "modify column CART_NUMBER int unsigned not null"; - q1=new QSqlQuery(sql); - delete q1; - } - delete q; - - SetVersion(257); -} - - -void MainObject::Revert259() const -{ - QString sql; - QSqlQuery *q; - QSqlQuery *q1; - - for(int i=0;i<168;i++) { - sql=QString().sprintf("alter table SERVICES add column CLOCK%d char(64)",i); - q=new QSqlQuery(sql); - delete q; - } - - sql=QString("select SERVICE_NAME,HOUR,CLOCK_NAME from SERVICE_CLOCKS"); - q=new QSqlQuery(sql); - while(q->next()) { - sql=QString("update SERVICES set ")+ - QString().sprintf("CLOCK%d=",q->value(1).toInt()); - if(q->value(2).isNull()) { - sql+="null "; - } - else { - sql+="\""+RDEscapeString(q->value(2).toString())+"\" "; - } - sql+="where NAME=\""+RDEscapeString(q->value(0).toString())+"\""; - q1=new QSqlQuery(sql); - delete q1; - } - delete q; - - sql=QString("drop table SERVICE_CLOCKS"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(258); -} - - -void MainObject::Revert260() const -{ - QString sql; - QSqlQuery *q; - - sql=QString("alter table USERS drop column WEBAPI_AUTH_TIMEOUT"); - q=new QSqlQuery(sql); - delete q; - - sql=QString("drop table WEBAPI_AUTHS"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(259); -} - - -void MainObject::Revert261() const -{ - QString sql; - QSqlQuery *q; - - sql=QString("alter table CUTS drop column SHA1_HASH"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(260); -} - - -void MainObject::Revert262() const -{ - QString sql; - QSqlQuery *q; - - sql=QString("alter table USERS drop column LOCAL_AUTH"); - q=new QSqlQuery(sql); - delete q; - - sql=QString("alter table USERS drop column PAM_SERVICE"); - q=new QSqlQuery(sql); - delete q; - - sql=QString("drop index IPV4_ADDRESS_IDX on STATIONS"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(261); -} - - -void MainObject::Revert263() const -{ - // Nothing to do here as this is a pseudo-schema change. - - SetVersion(262); -} - - -void MainObject::Revert264() const -{ - QString sql; - QSqlQuery *q; - - sql="alter table SYSTEM drop column FIX_DUP_CART_TITLES"; - q=new QSqlQuery(sql); - delete q; - - SetVersion(263); -} - - -void MainObject::Revert265() const -{ - QString sql; - QSqlQuery *q; - - sql="alter table SYSTEM drop column SHOW_USER_LIST"; - q=new QSqlQuery(sql); - delete q; - - SetVersion(264); -} - - -void MainObject::Revert266() const -{ - // Nothing to do here as this is a pseudo-schema change. - - SetVersion(265); -} - - -void MainObject::Revert267() const -{ - QString sql; - QSqlQuery *q; - - sql="alter table CUTS drop column ORIGIN_LOGIN_NAME"; - q=new QSqlQuery(sql); - delete q; - - sql="alter table CUTS drop column SOURCE_HOSTNAME"; - q=new QSqlQuery(sql); - delete q; - - SetVersion(266); -} - - -void MainObject::Revert268() const -{ - QString sql; - QSqlQuery *q; - - sql="alter table DROPBOXES drop column FORCE_TO_MONO"; - q=new QSqlQuery(sql); - delete q; - - SetVersion(267); -} - - -void MainObject::Revert269() const -{ - QString sql; - QSqlQuery *q; - - sql="alter table GROUPS drop column DEFAULT_CUT_LIFE"; - q=new QSqlQuery(sql); - delete q; - - SetVersion(268); -} - -void MainObject::Revert270() const -{ - QString sql; - QSqlQuery *q; - - sql="alter table STATIONS drop column SHORT_NAME"; - q=new QSqlQuery(sql); - delete q; - - SetVersion(269); -} - - -void MainObject::Revert271() const -{ - QString sql; - QSqlQuery *q; - sql=QString("alter table DROPBOXES drop column SEGUE_LEVEL, ")+ - "drop column SEGUE_LENGTH"; - q=new QSqlQuery(sql); - delete q; - - SetVersion(270); -} - - -void MainObject::Revert272() const -{ - QString sql; - QSqlQuery *q; - sql=QString("drop table USER_SERVICE_PERMS"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(271); -} - - -void MainObject::Revert273() const -{ - QString sql; - QSqlQuery *q; - - sql=QString("alter table LOGS drop column LOCK_DATETIME"); - q=new QSqlQuery(sql); - delete q; - - sql=QString("alter table LOGS drop column LOCK_IPV4_ADDRESS"); - q=new QSqlQuery(sql); - delete q; - - sql=QString("alter table LOGS drop column LOCK_STATION_NAME"); - q=new QSqlQuery(sql); - delete q; - - sql=QString("alter table LOGS drop column LOCK_USER_NAME"); - q=new QSqlQuery(sql); - delete q; - - SetVersion(272); -} - - -void MainObject::Revert274() const -{ - QString sql; - RDSqlQuery *q; - - sql=QString("alter table LOGS drop index LOCK_GUID_IDX"); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table LOGS drop column LOCK_GUID"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(273); -} - - -void MainObject::Revert275() const -{ - QString sql; - RDSqlQuery *q; - - sql=QString("alter table SERVICES drop column LOG_SHELFLIFE_ORIGIN"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(274); -} - - -void MainObject::Revert276() const -{ - QString sql; - RDSqlQuery *q; - - sql=QString("alter table SYSTEM drop column NOTIFICATION_ADDRESS"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(275); -} - - -void MainObject::Revert277() const -{ - QString sql; - RDSqlQuery *q; - - sql=QString("alter table USERS drop column WEBGET_LOGIN_PRIV"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(276); -} - - -void MainObject::Revert278() const -{ - QString sql; - RDSqlQuery *q; - RDSqlQuery *q1; - - for(int i=2;i>=0;i--) { - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("LOG_RML%d char(255) after DESCRIPTION_TEMPLATE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("UDP_STRING%d char(255) after DESCRIPTION_TEMPLATE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("UDP_PORT%d int unsigned after DESCRIPTION_TEMPLATE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("UDP_ADDR%d char(255) after DESCRIPTION_TEMPLATE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("LOG%d_START_MODE int default 0 ",i)+ - "after AUDITION_PREROLL"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("LOG%d_NEXT_CART int unsigned default 0 ",i)+ - "after AUDITION_PREROLL"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("LOG%d_NOW_CART int unsigned default 0 ",i)+ - "after AUDITION_PREROLL"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("LOG%d_LOG_LINE int default -1 ",i)+ - "after AUDITION_PREROLL"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("LOG%d_LOG_ID int default -1 ",i)+ - "after AUDITION_PREROLL"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("LOG%d_RUNNING enum('N','Y') default 'N' ",i)+ - "after AUDITION_PREROLL"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("LOG%d_CURRENT_LOG char(64) ",i)+ - "after AUDITION_PREROLL"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("LOG%d_LOG_NAME char(64) ",i)+ - "after AUDITION_PREROLL"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("LOG%d_AUTO_RESTART enum('N','Y') default 'N' ",i)+ - "after AUDITION_PREROLL"; - q=new RDSqlQuery(sql,false); - delete q; - } - - sql=QString("select ")+ - "STATION_NAME,"+ // 00 - "MACHINE,"+ // 01 - "START_MODE,"+ // 02 - "AUTO_RESTART,"+ // 03 - "LOG_NAME,"+ // 04 - "CURRENT_LOG,"+ // 05 - "RUNNING,"+ // 06 - "LOG_ID,"+ // 07 - "LOG_LINE,"+ // 08 - "NOW_CART,"+ // 09 - "NEXT_CART,"+ // 10 - "UDP_ADDR,"+ // 11 - "UDP_PORT,"+ // 12 - "UDP_STRING,"+ // 13 - "LOG_RML "+ // 14 - "from LOG_MACHINES where "+ - "MACHINE<3"; - q=new RDSqlQuery(sql,false); - while(q->next()) { - sql=QString("update RDAIRPLAY set ")+ - QString().sprintf("UDP_ADDR%d=\"",q->value(1).toInt())+ - RDEscapeString(q->value(11).toString())+"\","+ - QString().sprintf("UDP_PORT%d=%u,", - q->value(1).toInt(),q->value(12).toUInt())+ - QString().sprintf("UDP_STRING%d=\"",q->value(1).toInt())+ - RDEscapeString(q->value(13).toString())+"\","+ - QString().sprintf("LOG_RML%d=\"",q->value(1).toInt())+ - RDEscapeString(q->value(14).toString())+"\","+ - QString().sprintf("LOG%d_START_MODE=%d,", - q->value(1).toInt(),q->value(2).toInt())+ - QString().sprintf("LOG%d_AUTO_RESTART=\"",q->value(1).toInt())+ - RDEscapeString(q->value(3).toString())+"\","+ - QString().sprintf("LOG%d_LOG_NAME=\"",q->value(1).toInt())+ - RDEscapeString(q->value(4).toString())+"\","+ - QString().sprintf("LOG%d_CURRENT_LOG=\"",q->value(1).toInt())+ - RDEscapeString(q->value(5).toString())+"\","+ - QString().sprintf("LOG%d_RUNNING=\"",q->value(1).toInt())+ - RDEscapeString(q->value(6).toString())+"\","+ - QString().sprintf("LOG%d_LOG_ID=%d,", - q->value(1).toInt(),q->value(7).toInt())+ - QString().sprintf("LOG%d_LOG_LINE=%d,", - q->value(1).toInt(),q->value(8).toInt())+ - QString().sprintf("LOG%d_NOW_CART=%d,", - q->value(1).toInt(),q->value(9).toInt())+ - QString().sprintf("LOG%d_NEXT_CART=%d ", - q->value(1).toInt(),q->value(10).toInt())+ - "where STATION=\""+RDEscapeString(q->value(0).toString())+"\""; - q1=new RDSqlQuery(sql,false); - delete q1; - } - delete q; - - sql=QString("drop table LOG_MACHINES"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(277); -} - - -void MainObject::Revert279() const -{ - QString sql; - RDSqlQuery *q; - - sql=QString("delete from RDAIRPLAY_CHANNELS where INSTANCE>=100"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(278); -} - - -void MainObject::Revert280() const -{ - QString sql; - RDSqlQuery *q; - - sql=QString("delete from LOG_MODES where MACHINE>=100"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(279); -} - - -void MainObject::Revert281() const -{ - QString sql; - RDSqlQuery *q; - - sql=QString("alter table RDAIRPLAY drop column VIRTUAL_EXIT_CODE"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(280); -} - - -void MainObject::Revert282() const -{ - QString sql; - RDSqlQuery *q; - - for(int i=7;i>=0;i--) { - sql=QString("alter table STATIONS add column ")+ - QString().sprintf("CARD%d_OUTPUTS int default -1 after ALSA_VERSION",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table STATIONS add column ")+ - QString().sprintf("CARD%d_INPUTS int default -1 after ALSA_VERSION",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table STATIONS add column ")+ - QString().sprintf("CARD%d_NAME char(64) after ALSA_VERSION",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table STATIONS add column ")+ - QString().sprintf("CARD%d_DRIVER int default 0 after ALSA_VERSION",i); - q=new RDSqlQuery(sql,false); - delete q; - } - - sql=QString("drop table AUDIO_CARDS"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(281); -} - - -void MainObject::Revert283() const -{ - QString sql; - RDSqlQuery *q; - RDSqlQuery *q1; - - sql=QString("create table if not exists AUDIO_PORTS (")+ - "ID int unsigned not null primary key AUTO_INCREMENT,"+ - "STATION_NAME char(64) not null,"+ - "CARD_NUMBER int not null,"+ - "CLOCK_SOURCE int default 0,"+ - "INPUT_0_LEVEL int default 0,"+ - "INPUT_0_TYPE int default 0,"+ - "INPUT_0_MODE int default 0,"+ - "INPUT_1_LEVEL int default 0,"+ - "INPUT_1_TYPE int default 0,"+ - "INPUT_1_MODE int default 0,"+ - "INPUT_2_LEVEL int default 0,"+ - "INPUT_2_TYPE int default 0,"+ - "INPUT_2_MODE int default 0,"+ - "INPUT_3_LEVEL int default 0,"+ - "INPUT_3_TYPE int default 0,"+ - "INPUT_3_MODE int default 0,"+ - "INPUT_4_LEVEL int default 0,"+ - "INPUT_4_TYPE int default 0,"+ - "INPUT_4_MODE int default 0,"+ - "INPUT_5_LEVEL int default 0,"+ - "INPUT_5_TYPE int default 0,"+ - "INPUT_5_MODE int default 0,"+ - "INPUT_6_LEVEL int default 0,"+ - "INPUT_6_TYPE int default 0,"+ - "INPUT_6_MODE int default 0,"+ - "INPUT_7_LEVEL int default 0,"+ - "INPUT_7_TYPE int default 0,"+ - "INPUT_7_MODE int default 0,"+ - "OUTPUT_0_LEVEL int default 0,"+ - "OUTPUT_1_LEVEL int default 0,"+ - "OUTPUT_2_LEVEL int default 0,"+ - "OUTPUT_3_LEVEL int default 0,"+ - "OUTPUT_4_LEVEL int default 0,"+ - "OUTPUT_5_LEVEL int default 0,"+ - "OUTPUT_6_LEVEL int default 0,"+ - "OUTPUT_7_LEVEL int default 0,"+ - "index STATION_NAME_IDX (STATION_NAME),"+ - "index CARD_NUMBER_IDX (CARD_NUMBER))"+ - rev_config->createTablePostfix(); - q=new RDSqlQuery(sql,false); - delete q; - sql=QString("select NAME from STATIONS"); - q=new RDSqlQuery(sql,false); - while(q->next()) { - for(int i=0;i<8;i++) { - sql=QString("insert into AUDIO_PORTS set ")+ - "STATION_NAME=\""+RDEscapeString(q->value(0).toString())+"\","+ - QString().sprintf("CARD_NUMBER=%d",i); - q1=new RDSqlQuery(sql,false); - delete q1; - } - } - delete q; - sql=QString("select ")+ - "STATION_NAME,"+ // 00 - "CARD_NUMBER,"+ // 01 - "PORT_NUMBER,"+ // 02 - "LEVEL,"+ // 03 - "TYPE,"+ // 04 - "MODE "+ // 05 - "from AUDIO_INPUTS where PORT_NUMBER<8"; - q=new RDSqlQuery(sql,false); - while(q->next()) { - sql=QString("update AUDIO_PORTS set ")+ - QString().sprintf("INPUT_%d_LEVEL=%d,", - q->value(2).toInt(),q->value(3).toInt())+ - QString().sprintf("INPUT_%d_TYPE=%d,", - q->value(2).toInt(),q->value(4).toInt())+ - QString().sprintf("INPUT_%d_MODE=%d where ", - q->value(2).toInt(),q->value(5).toInt())+ - "STATION_NAME=\""+RDEscapeString(q->value(0).toString())+"\" && "+ - QString().sprintf("CARD_NUMBER=%d",q->value(1).toInt()); - } - delete q; - sql=QString("drop table AUDIO_INPUTS"); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("select ")+ - "STATION_NAME,"+ // 00 - "CARD_NUMBER,"+ // 01 - "PORT_NUMBER,"+ // 02 - "LEVEL "+ // 03 - "from AUDIO_OUTPUTS where PORT_NUMBER<8"; - q=new RDSqlQuery(sql,false); - while(q->next()) { - sql=QString("update AUDIO_PORTS set ")+ - QString().sprintf("OUTPUT_%d_LEVEL=%d where ", - q->value(2).toInt(),q->value(3).toInt())+ - "STATION_NAME=\""+RDEscapeString(q->value(0).toString())+"\" && "+ - QString().sprintf("CARD_NUMBER=%d",q->value(1).toInt()); - q1=new RDSqlQuery(sql,false); - delete q1; - } - delete q; - sql=QString("drop table AUDIO_OUTPUTS"); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("select ")+ - "STATION_NAME,"+ // 00 - "CARD_NUMBER,"+ // 01 - "CLOCK_SOURCE "+ // 02 - "from AUDIO_CARDS where CARD_NUMBER<8"; - q=new RDSqlQuery(sql,false); - while(q->next()) { - sql=QString("update AUDIO_PORTS set ")+ - QString().sprintf("CLOCK_SOURCE=%d where ",q->value(2).toInt())+ - "STATION_NAME=\""+RDEscapeString(q->value(0).toString())+"\" && "+ - QString().sprintf("CARD_NUMBER=%d",q->value(1).toInt()); - q1=new RDSqlQuery(sql,false); - delete q1; - } - delete q; - sql=QString("alter table AUDIO_CARDS drop column CLOCK_SOURCE"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(282); -} - - -void MainObject::Revert284() const -{ - QString sql; - RDSqlQuery *q; - - sql=QString("alter table RDAIRPLAY add column INSTANCE int unsigned ")+ - "not null default 0 after STATION"; - q=new RDSqlQuery(sql,false); - delete q; - - for(int i=9;i>=0;i--) { - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("STOP_RML%d char(255) after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("START_RML%d char(255) after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("PORT%d int default 0 after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - QString().sprintf("CARD%d int default 0 after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - } - - sql=QString("alter table RDAIRPLAY add column ")+ - "OP_MODE int default 2 after TRANS_LENGTH"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDAIRPLAY add column ")+ - "START_MODE int default 0 after OP_MODE"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDPANEL add column INSTANCE int unsigned ")+ - "not null default 0 after STATION"; - q=new RDSqlQuery(sql,false); - delete q; - - for(int i=9;i>=6;i--) { - sql=QString("alter table RDPANEL add column ")+ - QString().sprintf("STOP_RML%d char(255) after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDPANEL add column ")+ - QString().sprintf("START_RML%d char(255) after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDPANEL add column ")+ - QString().sprintf("PORT%d int default 0 after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDPANEL add column ")+ - QString().sprintf("CARD%d int default 0 after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - } - for(int i=3;i>=2;i--) { - sql=QString("alter table RDPANEL add column ")+ - QString().sprintf("STOP_RML%d char(255) after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDPANEL add column ")+ - QString().sprintf("START_RML%d char(255) after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDPANEL add column ")+ - QString().sprintf("PORT%d int default 0 after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDPANEL add column ")+ - QString().sprintf("CARD%d int default 0 after INSTANCE",i); - q=new RDSqlQuery(sql,false); - delete q; - } - - sql=QString("alter table MATRICES alter column PORT drop default"); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table MATRICES alter column PORT_2 drop default"); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table MATRICES alter column INPUTS drop default"); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table MATRICES alter column OUTPUTS drop default"); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table MATRICES alter column GPIS drop default"); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table MATRICES alter column GPOS drop default"); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table REPLICATORS alter column TYPE_ID drop default"); - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(283); -} - - -void MainObject::Revert285() const -{ - QString sql; - RDSqlQuery *q; - - sql=QString("alter table CART add column ISRC char(12) after YEAR"); - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table DECKS add ")+ - "column DEFAULT_SAMPRATE int default 44100 after DEFAULT_CHANNELS"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDLIBRARY add ")+ - "column INPUT_STREAM int default 0 after INPUT_CARD"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDLIBRARY add ")+ - "column OUTPUT_STREAM int default 0 after OUTPUT_CARD"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDLIBRARY add ")+ - "column RECORD_GPI int default -1 after TRIM_THRESHOLD"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDLIBRARY add ")+ - "column PLAY_GPI int default -1 after RECORD_GPI"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDLIBRARY add ")+ - "column STOP_GPI int default -1 after PLAY_GPI"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDLIBRARY add ")+ - "column DEFAULT_SAMPRATE int default 44100 after DEFAULT_CHANNELS"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table RDLOGEDIT add ")+ - "column SAMPRATE int unsigned default 44100 after FORMAT"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table SERVICES add ")+ - "column TFC_START_OFFSET int after TFC_TITLE_LENGTH"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table SERVICES add ")+ - "column TFC_START_LENGTH int after TFC_START_OFFSET"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table SERVICES add ")+ - "column MUS_START_OFFSET int after MUS_TITLE_LENGTH"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table SERVICES add ")+ - "column MUS_START_LENGTH int after MUS_START_OFFSET"; - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(284); -} - - -void MainObject::Revert286() const -{ - QString sql; - RDSqlQuery *q; - - sql=QString("alter table SERVICES add ")+ - "column TFC_LENGTH_OFFSET int after TFC_LEN_SECONDS_LENGTH"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table SERVICES add ")+ - "column TFC_LENGTH_LENGTH int after TFC_LENGTH_OFFSET"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table SERVICES add ")+ - "column MUS_LENGTH_OFFSET int after MUS_LEN_SECONDS_LENGTH"; - q=new RDSqlQuery(sql,false); - delete q; - - sql=QString("alter table SERVICES add ")+ - "column MUS_LENGTH_LENGTH int after MUS_LENGTH_OFFSET"; - q=new RDSqlQuery(sql,false); - delete q; - - SetVersion(285); -} - - -int MainObject::GetVersion() const -{ - QString sql; - QSqlQuery *q; - int ret=0; - - sql=QString("select DB from VERSION"); - q=new QSqlQuery(sql); - if(q->first()) { - ret=q->value(0).toInt(); - } - - return ret; -} - - -void MainObject::SetVersion(int schema) const -{ - QString sql; - QSqlQuery *q; - - sql=QString().sprintf("update VERSION set DB=%d",schema); - q=new QSqlQuery(sql); - delete q; -} - - -int MainObject::MapSchema(const QString &ver) -{ - QString version=ver; - bool ok=false; - - // - // Version -> Schema Map - // - std::map version_map; - version_map["2.10"]=242; - version_map["2.11"]=245; - version_map["2.12"]=254; - version_map["2.13"]=255; - version_map["2.14"]=258; - version_map["2.15"]=259; - version_map["2.16"]=263; - version_map["2.17"]=268; - version_map["2.18"]=272; - version_map["2.19"]=275; - version_map["2.20"]=286; - - // - // Normalize String - // - if(version.left(1).lower()=="v") { - version=version.right(version.length()-1); - } - QStringList f0=f0.split(".",version); - if(f0.size()!=3) { - return 0; - } - for(int i=0;i<3;i++) { - f0[i].toInt(&ok); - if(!ok) { - return 0; - } - } - - // - // Lookup Schema - // - if(version_map.count(f0[0]+"."+f0[1])==0) { - return 0; - } - - return version_map[f0[0]+"."+f0[1]]; -} - - -int main(int argc,char *argv[]) -{ - QApplication a(argc,argv,false); - new MainObject(); - return a.exec(); -} diff --git a/utils/rdrevert/rdrevert.h b/utils/rdrevert/rdrevert.h deleted file mode 100644 index 12ff64fc..00000000 --- a/utils/rdrevert/rdrevert.h +++ /dev/null @@ -1,94 +0,0 @@ -// rdrevert.h -// -// Revert the Rivendell database schema to an earlier version. -// -// (C) Copyright 2016 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 -// published by the Free Software Foundation. -// -// 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 this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// - -#ifndef RDREVERT_H -#define RDREVERT_H - -#include - -#include - -#include -#include - -#define RDREVERT_BASE_SCHEMA 242 -#define RDREVERT_USAGE "[options]\n" - -class MainObject : public QObject -{ - public: - MainObject(QObject *parent=0); - - private: - void Revert(int schema) const; - void Revert243() const; - void Revert244() const; - void Revert245() const; - void Revert246() const; - void Revert247() const; - void Revert248() const; - void Revert249() const; - void Revert250() const; - void Revert251() const; - void Revert252() const; - void Revert253() const; - void Revert254() const; - void Revert255() const; - void Revert256() const; - void Revert257() const; - void Revert258() const; - void Revert259() const; - void Revert260() const; - void Revert261() const; - void Revert262() const; - void Revert263() const; - void Revert264() const; - void Revert265() const; - void Revert266() const; - void Revert267() const; - void Revert268() const; - void Revert269() const; - void Revert270() const; - void Revert271() const; - void Revert272() const; - void Revert273() const; - void Revert274() const; - void Revert275() const; - void Revert276() const; - void Revert277() const; - void Revert278() const; - void Revert279() const; - void Revert280() const; - void Revert281() const; - void Revert282() const; - void Revert283() const; - void Revert284() const; - void Revert285() const; - void Revert286() const; - int GetVersion() const; - void SetVersion(int schema) const; - int MapSchema(const QString &ver); - bool rev_use_deadzone; - RDConfig *rev_config; - QSqlDatabase *rev_db; -}; - - -#endif // RDREVERT_H