From 4e0b017665661b09730b78cc3ce542e26d68a28e Mon Sep 17 00:00:00 2001 From: CT1DRB Date: Mon, 3 Nov 2008 19:14:56 +0000 Subject: [PATCH] To match hamlib new version and cosmetic changes to delete old logbooks --- yfk | 24 +++++++++++++++++++++--- yfksubs.pl | 44 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/yfk b/yfk index 590acfa..070de16 100755 --- a/yfk +++ b/yfk @@ -26,7 +26,7 @@ use DBI; # Database interface use Curses; use Net::FTP; # upload of online log or backup -my $prefix="/usr/local"; +my $prefix="/usr/"; if (-f './yfk' && -f './yfksubs.pl' && -f 'THANKS') { # we're in the source directory, source the local copy @@ -700,7 +700,7 @@ while ($status == 2) { "ADIF Import - Import QSOs to current logbook", "ADIF Export - Export QSOs in ADIF Format", "Update Onlinelog - Update the online searchable log", - "Select Logbook - Change active Logbook or create new one", + "Select Logbook - Change active Logbook or create/delete new one", "Awards/Statistics - DXCC, WAZ, WPX, IOTA etc. plus statistics", "Edit Name/QTH DB - Edit the database used to save Names and QTHs", "Import from LOTW - Read LOTW report and update the confirmations", @@ -1435,7 +1435,7 @@ while ($status == 10) { attron($wmain, COLOR_PAIR(4)); addstr($whead, 0,0, "YFKlog v$yfkver - Select Log mode - Active Logbook: ". "\U$mycall"." - DB: $dbname @ $dbserver".' ' x 30); - addstr($whelp, 0,0, 'Chose one of the logs or create a new one ..'.' 'x50); + addstr($whelp, 0,0, 'Chose one of the logs or create/delete a new one ..'.' 'x50); erase($wmain); addstr($wmain,0,0, ' 'x(80*22)); # blue background addstr($wmain, 2,18, 'Select an existing logbook or create a new log!'); @@ -1446,6 +1446,8 @@ while ($status == 10) { @logs = &getlogs(); # get list of logbooks push(@logs, " Create new Logbook "); # add option to make new one @logs = sort @logs; + push(@logs, " Delete Logbook "); # add option to make new one + @logs = sort @logs; # After dorting, the " Create new Logbook " entry will be at the first # position because it starts with a whitespace. This is needed because the # case of creating a new logbook has to be treated different. @@ -1480,6 +1482,22 @@ while ($status == 10) { refresh($wmain); getch(); } + elsif ($choice == 1) { # second item -> delete old log + curs_set(1); # cursor visible + # Ask for the name to delete. +# my $old = &askbox(10, 15, 4, 50, '[a-zA-Z0-9/]', +# "Enter a name (callsign) to delete:", ''); +# curs_set(0); # cursr invisible +# my $msg = &oldlogtable($old); +# addstr($wmain, 15, (40-(length($msg." ($old)")/2)), $msg." ($old)"); +# if ($msg =~ /successfully/) { # new call OK +# $mycall = "\L$new"; # take it as MYCALL +# $mycall =~ s/\//_/g; # / -> _ +# &changemycall($mycall); # change $mycall also in yfksubs.pl +# } + refresh($wmain); + getch(); + } else { # change $mycall to selected log $mycall = $logs[$choice]; # Callsign is here $mycall =~ s/\//_/g; # change / to _ diff --git a/yfksubs.pl b/yfksubs.pl index 25e1920..ac891a1 100644 --- a/yfksubs.pl +++ b/yfksubs.pl @@ -86,7 +86,7 @@ our $checklogs = ''; # add. logs to chk fr prev QSOs our $lotwdetails='0'; # LOTW import details? our $autoqueryrig='0'; # Query rig at new QSO? our $directory='/tmp/'; # where to look for stuff -our $prefix="/usr/local"; # may be changed by 'make' +our $prefix="/usr/"; # may be changed by 'make' my $db=''; # sqlite or mysql? our $fieldorder= # TAB/Field order. 'CALL DATE TON TOFF BAND MODE QTH NAME QSLS QSLR RSTS RSTR REM PWR'; @@ -3654,6 +3654,47 @@ sub newlogtable { } } # newlogtable +############################################################################## +# &oldlogtable Erase an old logbook table in the database with the name +# "log_\L$_[0]$", for example log_dj1yfk. If the callsign includes a "/", it +# will be converted into a "_" because "/" is not allowed in a table name. +############################################################################## + +sub oldlogtable { + my $call = $_[0]; # callsign of the new database + + my $filename = "$prefix/share/yfklog/db_log.sql"; + if ($db eq 'sqlite') { + $filename = "$prefix/share/yfklog/db_log.sqlite"; + } + +# open DB, $filename; # database definition in this file +# my @db = ; # read database def. into @db + + # We assume that the callsign in $_[0] is valid, because the &askbox() + # which produced it only accepted valid callsign-letters. + # only exception: empty callsign! + +# if ($call eq '') { +# return "**** Invalid callsign! ****"; +# } + +# $call =~ tr/\//_/; # convert "/" to "_" +# $call =~ tr/[A-Z]/[a-z]/; # make call lowercase + + + # Now check if there is also a table existing with the same name + +# if (&tableexists("log_$call")) { # If logbook does not yet exist, create it +# my $db = "@db"; +# $db =~ s/MYCALL/$call/g;# replace the callsign placeholder +# $dbh->delete($db); # create it! +# return "Logbook successfully erased!"; +# } +# else { # log already existed +# return "Logbook with same name already exists!"; +# } +} # oldlogtable ############################################################################## # choseeditqso - Choses a QSO in the Edit & Search Mode which has to be # edited. It gets references to the @qso-array with the search criteria, and @@ -5048,7 +5089,6 @@ sub queryrig { print $sock "f\n"; $freq = <$sock>; chomp($freq); - <$sock>; # rigctld sends an extra line "END" print $sock "m\n"; $mode = <$sock>;