Mercurial > ~darius > hgwebdir.cgi > mservtk
comparison mservtk.tcl @ 6:b370e0bbe050
Remove the check every second, since it breaks stuff :-/
author | darius |
---|---|
date | Thu, 12 Oct 2000 11:41:22 +0000 |
parents | b6c495b5eeda |
children | abe05fb9c2a6 |
comparison
equal
deleted
inserted
replaced
5:b6c495b5eeda | 6:b370e0bbe050 |
---|---|
70 focus -force .; | 70 focus -force .; |
71 | 71 |
72 gui_updatesongs; | 72 gui_updatesongs; |
73 gui_updatequeue; | 73 gui_updatequeue; |
74 | 74 |
75 gui_updateinfo; | |
75 update_timer; | 76 update_timer; |
76 | 77 |
77 while {1} { | 78 while {1} { |
78 vwait state; | 79 vwait state; |
79 | 80 |
356 pack .top.tinfo.sub.author -side top -expand 0; | 357 pack .top.tinfo.sub.author -side top -expand 0; |
357 label .top.tinfo.sub.title -text "Title:"; | 358 label .top.tinfo.sub.title -text "Title:"; |
358 pack .top.tinfo.sub.title -side top -expand 0; | 359 pack .top.tinfo.sub.title -side top -expand 0; |
359 label .top.tinfo.sub.length -text "Length:"; | 360 label .top.tinfo.sub.length -text "Length:"; |
360 pack .top.tinfo.sub.length -side top -expand 0; | 361 pack .top.tinfo.sub.length -side top -expand 0; |
361 label .top.tinfo.sub.time -text "Time:"; | 362 # label .top.tinfo.sub.time -text "Time:"; |
362 pack .top.tinfo.sub.time -side top -expand 0; | 363 # pack .top.tinfo.sub.time -side top -expand 0; |
363 label .top.tinfo.sub.album -text "Album:"; | 364 label .top.tinfo.sub.album -text "Album:"; |
364 pack .top.tinfo.sub.album -side top -expand 0; | 365 pack .top.tinfo.sub.album -side top -expand 0; |
365 label .top.tinfo.sub.misc -text "Misc:"; | 366 label .top.tinfo.sub.misc -text "Misc:"; |
366 pack .top.tinfo.sub.misc -side top -expand 0; | 367 pack .top.tinfo.sub.misc -side top -expand 0; |
367 label .top.tinfo.sub.rate1 -text "Rating:"; | 368 label .top.tinfo.sub.rate1 -text "Rating:"; |
418 global songs state; | 419 global songs state; |
419 | 420 |
420 set tmp [lindex [lindex [array get songs *:listid:$id] 1] 0]; | 421 set tmp [lindex [lindex [array get songs *:listid:$id] 1] 0]; |
421 log "%s" "Queue - '$songs($tmp:name)' by '$songs($tmp:author)' ($tmp)"; | 422 log "%s" "Queue - '$songs($tmp:name)' by '$songs($tmp:author)' ($tmp)"; |
422 | 423 |
424 set cookie [acquire_lock]; | |
423 n_write "QUEUE [split $tmp {:}]"; | 425 n_write "QUEUE [split $tmp {:}]"; |
424 n_getrtn rtn; | 426 n_getrtn rtn; |
425 | 427 release_lock $cookie; |
428 | |
426 if {$rtn(code) != 247} { | 429 if {$rtn(code) != 247} { |
427 if {$rtn(code) == 510} { | 430 if {$rtn(code) == 510} { |
428 msg_box "Queue" "You can't have the same\nsong in the queue twice!"; | 431 msg_box "Queue" "You can't have the same\nsong in the queue twice!"; |
429 } else { | 432 } else { |
430 log "%s" "Failed to queue track ($rtn(code) $rtn(data))"; | 433 log "%s" "Failed to queue track ($rtn(code) $rtn(data))"; |
520 log "%s" "Writing $cmd"; | 523 log "%s" "Writing $cmd"; |
521 n_write "$cmd"; | 524 n_write "$cmd"; |
522 n_getrtn rtn; | 525 n_getrtn rtn; |
523 release_lock $cookie; | 526 release_lock $cookie; |
524 | 527 |
525 log "%s" "Control Got $rtn(code) $rtn(data)"; | 528 # log "%s" "Control Got $rtn(code) $rtn(data)"; |
526 } | 529 } |
527 | 530 |
528 proc gui_top {} { | 531 proc gui_top {} { |
529 global state; | 532 global state; |
530 | 533 |
587 } | 590 } |
588 | 591 |
589 proc gui_updatequeue {} { | 592 proc gui_updatequeue {} { |
590 global state songs queue; | 593 global state songs queue; |
591 | 594 |
592 log "%s" "Updating queue"; | 595 # log "%s" "Updating queue"; |
593 | 596 |
594 .bot.queue.list delete 0 end; | 597 .bot.queue.list delete 0 end; |
595 | 598 |
596 con_getqueue queue; | 599 con_getqueue queue; |
597 | 600 |
663 n_write "STATUS"; | 666 n_write "STATUS"; |
664 n_getrtn rtn; | 667 n_getrtn rtn; |
665 release_lock $cookie; | 668 release_lock $cookie; |
666 | 669 |
667 if {$rtn(code) != 222} { | 670 if {$rtn(code) != 222} { |
668 set left "x:xx"; | |
669 set played "x:xx"; | 671 set played "x:xx"; |
670 } else { | 672 } else { |
671 set played [lindex [split [lindex $rtn(lines) 0] "\t"] 8]; | 673 set played [lindex [split [lindex $rtn(lines) 0] "\t"] 8]; |
672 | |
673 # scan $played "%d:%d" played_m played_s; | |
674 # set played [expr ($played_m * 60) + $played_s]; | |
675 # scan $length "%d:%f" len_m len_s; | |
676 # set len [expr ($len_m * 60) + $len_s]; | |
677 | |
678 # set left [expr $len - $played]; | |
679 # set left_m [expr int($left / 60)]; | |
680 # set left [format "%02d:%02d" $left_m [expr int($left - ($left_m * 60))]]; | |
681 } | 674 } |
682 | 675 |
683 .top.tinfo.sub.author configure -text "Author: $author"; | 676 .top.tinfo.sub.author configure -text "Author: $author"; |
684 .top.tinfo.sub.title configure -text "Title: $title"; | 677 .top.tinfo.sub.title configure -text "Title: $title"; |
685 .top.tinfo.sub.length configure -text "Length: $length"; | 678 .top.tinfo.sub.length configure -text "Length: $length"; |
686 .top.tinfo.sub.time configure -text "Time: $played"; | 679 # .top.tinfo.sub.time configure -text "Time: $played"; |
687 .top.tinfo.sub.album configure -text "Album: $album"; | 680 .top.tinfo.sub.album configure -text "Album: $album"; |
688 .top.tinfo.sub.misc configure -text "Misc: $misc"; | 681 .top.tinfo.sub.misc configure -text "Misc: $misc"; |
689 .top.tinfo.sub.rate1 configure -text "Rating: $rate1"; | 682 .top.tinfo.sub.rate1 configure -text "Rating: $rate1"; |
690 .top.tinfo.sub.rate2 configure -text "Temporally Adjusted: $rate2"; | 683 .top.tinfo.sub.rate2 configure -text "Temporally Adjusted: $rate2"; |
691 .top.tinfo.sub.vol configure -text "Volume: $vol"; | 684 .top.tinfo.sub.vol configure -text "Volume: $vol"; |
712 | 705 |
713 set queue($i) $id; | 706 set queue($i) $id; |
714 incr i; | 707 incr i; |
715 } | 708 } |
716 } elseif {$rtn(code) == 404} { | 709 } elseif {$rtn(code) == 404} { |
717 log "%s" "Queue empty"; | 710 # log "%s" "Queue empty"; |
718 } else { | 711 } else { |
719 log "%s" "Failed to get queue ($rtn(code) $rtn(data))"; | 712 log "%s" "Failed to get queue ($rtn(code) $rtn(data))"; |
720 } | 713 } |
721 } | 714 } |
722 | 715 |
787 } | 780 } |
788 } | 781 } |
789 | 782 |
790 proc update_timer {} { | 783 proc update_timer {} { |
791 | 784 |
792 gui_updateinfo; | 785 # gui_updateinfo; |
793 | 786 |
787 | |
794 after 900 update_timer; | 788 after 900 update_timer; |
795 } | 789 } |
796 | 790 |
797 proc con_mserv {} { | 791 proc con_mserv {} { |
798 global state; | 792 global state; |
807 fileevent $state(serv_fd) readable n_rtinput; | 801 fileevent $state(serv_fd) readable n_rtinput; |
808 fconfigure $state(serv_fd) -blocking 0; | 802 fconfigure $state(serv_fd) -blocking 0; |
809 | 803 |
810 # Greeting from server | 804 # Greeting from server |
811 n_getrtn rtn; | 805 n_getrtn rtn; |
812 puts $rtn(data); | 806 log "%s" $rtn(data); |
813 if {$rtn(code) != "200"} { | 807 if {$rtn(code) != "200"} { |
814 error "Server failed to send greeting"; | 808 error "Server failed to send greeting"; |
815 } | 809 } |
816 | 810 |
817 # Login | 811 # Login |
851 } | 845 } |
852 | 846 |
853 proc n_rthandler {code data} { | 847 proc n_rthandler {code data} { |
854 global songs; | 848 global songs; |
855 | 849 |
856 log "%s" "Got RT - $code $data"; | 850 # log "%s" "Got RT - $code $data"; |
857 | 851 |
858 switch -- $code { | 852 switch -- $code { |
859 600 { | 853 600 { |
860 log "%s" "User '$data' connected"; | 854 log "%s" "User '$data' connected"; |
861 } | 855 } |
863 601 { | 857 601 { |
864 log "%s" "User '$data' disconnected"; | 858 log "%s" "User '$data' disconnected"; |
865 } | 859 } |
866 | 860 |
867 240 - | 861 240 - |
862 602 - | |
863 615 - | |
868 618 - | 864 618 - |
869 619 - | 865 619 - |
870 620 - | 866 620 - |
871 622 - | 867 622 - |
872 623 - | 868 623 - |
873 627 - | 869 627 - |
874 628 - | 870 628 - |
875 629 { | 871 629 { |
876 log "%s" "Updating queue on idle"; | 872 # log "%s" "Updating queue on idle"; |
873 gui_updateinfo; | |
877 gui_updatequeue; | 874 gui_updatequeue; |
878 } | 875 } |
879 | 876 |
880 default { | 877 default { |
881 log "%s" "Got unhandled RT event $code $data"; | 878 log "%s" "Got unhandled RT event $code $data"; |
1044 | 1041 |
1045 log "%s" "$op, now $state(lock)"; | 1042 log "%s" "$op, now $state(lock)"; |
1046 } | 1043 } |
1047 | 1044 |
1048 if {[catch {main} msg]} { | 1045 if {[catch {main} msg]} { |
1049 catch {tk_dialog .dummy "Error!" $msg error 0 "OK"}; | 1046 catch {tk_dialog .dummy "Error!" [format "%s\n%s" $msg $errorInfo] error 0 "OK"}; |
1050 } | 1047 exit 1; |
1051 | 1048 } |
1049 |