Changeset 1650 in ProjectBuilder for projects/CDDBeditor


Ignore:
Timestamp:
Oct 6, 2012, 9:10:51 PM (12 years ago)
Author:
Bruno Cornec
Message:
  • Adds support for logging, and an exit function
  • Fix a bug where the ind value was incorrect with only one CD leading to empty content !
File:
1 edited

Legend:

Unmodified
Added
Removed
  • projects/CDDBeditor/devel/CDDBeditor/bin/CDDBeditor

    r1641 r1650  
    2121use lib qw (lib);
    2222use locale;
    23 # > 2.27
     23# >= 2.27
    2424use CDDB_get qw( get_cddb get_discids );
    2525use Encode;
     
    139139    $pbdebug=-1;
    140140}
    141 pb_log_init($pbdebug, $pbLOG);
    142 
     141open(LOG, "> $ENV{HOME}/.CDDBeditor.log") || die "Unable to open $ENV{HOME}/.CDDBeditor.log";
     142pb_log_init($pbdebug, \*LOG);
    143143
    144144Newt::Init();
     
    190190$ce_config{"DOMAIN"} = "musique-ancienne.org";
    191191$ce_config{"USER"} = "bruno";
    192 $ce_config{"HELLO_ID"} = "$ce_config{\"USER\"} $ce_config{\"DOMAIN\"} fastrip 0.77";
     192# Requires 4 words exactly
     193$ce_config{"HELLO_ID"} = "$ce_config{\"USER\"} $ce_config{\"DOMAIN\"} CDDBEditor 0.5";
    193194
    194195# Copied from CDDB.pm
     
    206207# Need 23 char for track and time
    207208my $width = $ce_sl - 23;
    208 # Othe fields are limited to 5
     209# Other fields are limited to 5
    209210my $width2 = 5;
    210211my $host_entry = Newt::Entry($width, $flag, $ce_config{"CDDB_HOST"});
     
    259260
    260261Newt::Cls();
    261 exit 0 if ($data->Tag() eq "Quit");
     262cddbe_exit(0) if ($data->Tag() eq "Quit");
    262263
    263264if ($ce_config{"CDDB_MODE"} eq "http" ) {
     
    268269$ce_config{"CDDB_MODE"}=$ce_cddb_mode{$mode_group->Get()};
    269270$ce_config{"CD_DEVICE"}=$dev_entry->Get();
     271
     272pb_log(1,"After first screen\n");
     273pb_log(1,"ce_config is:\n");
     274pb_log(1,Dumper(%ce_config)."\n");
    270275
    271276# Components
     
    287292
    288293# Entering the loop
    289 for (my $i=0 ; ; $i++) {
    290     # Second panel to make user wait
     294for (my $i=0 ; ; $i++) { # Second panel to make user wait
    291295    Newt::Cls();
    292296    Newt::DrawRootText(ce_center_string($ce_title), 1, $ce_title);
     
    303307        # by default use first one
    304308        $ce_cd = $cecd[0] if (defined $cecd[0]);
     309        pb_log(1,"After get_cddb\n");
     310        pb_log(1,"cecd is:\n");
     311        pb_log(1,Dumper(@cecd)."\n");
    305312    }
    306313    $firsttime = 0;
     
    320327        $ind++;
    321328    }
     329    pb_log(1,"ind is: $ind\n");
    322330
    323331    if ($ind gt 1) {
     
    346354
    347355        Newt::Cls();
    348         exit 0 if ($data->Tag() eq "Quit");
     356        cddbe_exit(0) if ($data->Tag() eq "Quit");
    349357       
    350358        $ind=$user_group->Get();
     359    } else {
     360        # if only one CD, back to its number which is 0
     361        $ind--;
    351362    }
    352363    # Point now to the right CD
    353364    $ce_cd = $cecd[$ind];
     365    pb_log(1,"After CD choice\n");
     366    pb_log(1,"ce_cd is: \n");
     367    pb_log(1,Dumper($ce_cd)."\n");
    354368
    355369    if (not defined $ce_cd->{title}) {
     
    358372        $ce_cd->{id} = sprintf "%08x", $id->[0];
    359373
     374        pb_log(1,"After get_discids\n");
     375        pb_log(1,"id is:\n");
     376        pb_log(1,Dumper($id)."\n");
     377        pb_log(1,"ce_cd is:\n");
     378        pb_log(1,Dumper($ce_cd)."\n");
    360379        # Try to find it locally
    361380        my @d = glob("$ENV{'HOME'}/.cddb/*/$ce_cd->{id}");
     
    507526    Newt::Refresh();
    508527    Newt::Cls();
    509     exit 0 if ($data->Tag() eq "Quit");
     528    cddbe_exit(0) if ($data->Tag() eq "Quit");
     529
     530    pb_log(1,"Before sending\n");
     531    pb_log(1,"ce_cd is:\n");
     532    pb_log(1,Dumper($ce_cd)."\n");
    510533
    511534    # Send the data
     
    539562}
    540563Newt::Finished();
    541 exit 0;
     564cddbe_exit(0);
    542565
    543566# return the char to start printing a centered string based on screen size
     
    594617}
    595618
     619sub cddbe_exit {
     620
     621my $ret = shift;
     622close(LOG);
     623exit $ret
     624}
     625
    5966261;
Note: See TracChangeset for help on using the changeset viewer.