rwddemo 0.91 → 0.92
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.txt +32 -305
- data/code/01rwdcore/01rwdcore.rb +15 -13
- data/code/01rwdcore/jumplinkcommand.rb +30 -0
- data/code/01rwdcore/openhelpwindow.rb +26 -26
- data/code/01rwdcore/returntomain.rb +8 -8
- data/code/01rwdcore/rwdtinkerversion.rb +12 -13
- data/code/01rwdcore/rwdwindowreturn.rb +3 -5
- data/code/01rwdcore/test_cases.rb +115 -0
- data/code/01rwdcore/test_harness.rb +12 -0
- data/code/01rwdcore/uploadreturns.rb +62 -0
- data/code/dd0viewphoto/dd0viewphoto.rb +3 -4
- data/code/superant.com.rwdcalc/jumplinkupdate.rb +11 -0
- data/code/superant.com.rwdcalendar/helptexthashrwdschedule.rb +14 -0
- data/code/superant.com.rwdcalendar/openhelpwindowrwdschedule.rb +17 -0
- data/code/superant.com.rwdshell/helptexthashshell.rb +8 -1
- data/code/superant.com.rwdshell/openhelpwindowshell.rb +6 -0
- data/code/superant.com.rwdshell/runrwdshellwindow.rb +4 -1
- data/code/superant.com.rwdtinkerbackwindow/controlclient.rb +89 -92
- data/code/superant.com.rwdtinkerbackwindow/diagnostictab.rb +16 -18
- data/code/superant.com.rwdtinkerbackwindow/installapplet.rb +19 -18
- data/code/superant.com.rwdtinkerbackwindow/installgemapplet.rb +20 -19
- data/code/superant.com.rwdtinkerbackwindow/installremotegem.rb +19 -18
- data/code/superant.com.rwdtinkerbackwindow/listgemdirs.rb +7 -7
- data/code/superant.com.rwdtinkerbackwindow/listgemzips.rb +48 -49
- data/code/superant.com.rwdtinkerbackwindow/listinstalledfiles.rb +8 -7
- data/code/superant.com.rwdtinkerbackwindow/listzips.rb +22 -26
- data/code/superant.com.rwdtinkerbackwindow/loadconfigurationrecord.rb +32 -31
- data/code/superant.com.rwdtinkerbackwindow/loadconfigurationvariables.rb +14 -13
- data/code/superant.com.rwdtinkerbackwindow/network.rb +82 -82
- data/code/superant.com.rwdtinkerbackwindow/openappletname.rb +18 -17
- data/code/superant.com.rwdtinkerbackwindow/openhelpwindowtinkerwin2.rb +37 -37
- data/code/superant.com.rwdtinkerbackwindow/remotegemlist.rb +20 -20
- data/code/superant.com.rwdtinkerbackwindow/removeapplet.rb +33 -32
- data/code/superant.com.rwdtinkerbackwindow/runrwdtinkerbackwindow.rb +8 -9
- data/code/superant.com.rwdtinkerbackwindow/rwdtinkerwin2version.rb +10 -11
- data/code/superant.com.rwdtinkerbackwindow/saveconfigurationrecord.rb +19 -18
- data/code/superant.com.rwdtinkerbackwindow/viewappletcontents.rb +21 -20
- data/code/superant.com.rwdtinkerbackwindow/viewgemappletcontents.rb +23 -20
- data/configuration/language.dist +1 -1
- data/configuration/rwddemo.dist +3 -0
- data/configuration/rwdtinker.dist +3 -3
- data/configuration/tinkerwin2variables.dist +1 -1
- data/gui/frontwindow0/superant.com.rwdcalendar/hl9calendar.rwd +1 -1
- data/gui/frontwindow0/superant.com.shellscripts/3editscripts.rwd +1 -0
- data/gui/frontwindow0/viewlogo/cc0openphoto.rwd +22 -0
- data/gui/frontwindowselectionbegin/selectiontabbegin/selectiontabbegin.rwd +2 -7
- data/gui/frontwindowselections/superant.com.rwdtinkerwin2selectiontab/jumplinkcommands.rwd +15 -0
- data/gui/frontwindowselections/viewselectionzend/viewselectionend.rwd +3 -0
- data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/3copyright.rwd +1 -1
- data/gui/tinkerbackwindows/superant.com.rwdcalc/81jumplinkcommands.rwd +17 -0
- data/gui/tinkerbackwindows/superant.com.rwdshellbackwindow/46editscriptrecord.rwd +1 -1
- data/gui/tinkerbackwindows/superant.com.rwdshellbackwindow/94rwddiagnostics.rwd +0 -17
- data/gui/tinkerbackwindows/superant.com.rwdshellbackwindow/98jumplinkcommands.rwd +17 -0
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/70rwddiagnostics.rwd +12 -16
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/81jumplinkcommands.rwd +17 -0
- data/init.rb +231 -228
- data/rwd_files/HowTo_Tinker.txt +20 -0
- data/rwdconfig.dist +6 -2
- data/tests/makedist.rb +36 -7
- metadata +54 -69
- data/code/superant.com.rwdshell/runrwdshellmenu1.rb +0 -57
- data/configuration/language.cnf +0 -7
- data/configuration/rwdapplicationidentity.cnf +0 -3
- data/configuration/rwdcalc.cnf +0 -7
- data/configuration/rwdcalendar.cnf +0 -10
- data/configuration/rwdshell.cnf +0 -3
- data/configuration/rwdtinker.cnf +0 -15
- data/configuration/tinkerwin2variables.cnf +0 -17
- data/extras/cmdline_parse +0 -47
- data/extras/config_file +0 -69
- data/extras/errorMsg +0 -19
- data/extras/makePlaylist +0 -34
- data/extras/mp3controld +0 -289
- data/extras/playlist +0 -186
- data/extras/showHelp +0 -18
- data/gui/frontwindowselections/superant.com.rwdcalcselectiontab/rwdcalc.rwd +0 -12
- data/gui/frontwindowselections/superant.com.rwdshellselectiontab/rwdshellbackwindowselectiontab.rwd +0 -12
- data/gui/frontwindowselections/superant.com.rwdtinkerwin2selectiontab/rwdwin2selectiontab.rwd +0 -12
- data/gui/helpaboutinstalled/superant.com.rwdwin2helpabout/1appname.rwd +0 -4
- data/gui/helpaboutinstalled/superant.com.rwdwin2helpabout/3copyright.rwd +0 -3
- data/gui/helpaboutinstalled/superant.com.rwdwin2helpabout/5version.rwd +0 -10
- data/gui/tinkerbackwindows/superant.com.rwdcalc/98returntab.rwd +0 -11
- data/gui/tinkerbackwindows/superant.com.rwdshellbackwindow/v9returntab.rwd +0 -11
- data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/80tab1.rwd +0 -11
- data/rwdconfig.cnf +0 -6
data/extras/cmdline_parse
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# --- Parse command line ---
|
3
|
-
#
|
4
|
-
# Author: Magnus Engstr�m
|
5
|
-
# Email: magnus@gisab.se
|
6
|
-
# File: cmdline_parse
|
7
|
-
#
|
8
|
-
# Description
|
9
|
-
# -----------
|
10
|
-
# Parses the commandline and
|
11
|
-
# returns a hash with the
|
12
|
-
# switch as key and the
|
13
|
-
# value as value :)
|
14
|
-
# --------------------------
|
15
|
-
|
16
|
-
class Commandline
|
17
|
-
def Commandline::parse()
|
18
|
-
|
19
|
-
params = Hash::new() # Could be useful to have something to put the commandline in ;)
|
20
|
-
key = false # Just a really ugly hack to keep track on if we're reading key or value
|
21
|
-
foo = '' # Keeps the key name
|
22
|
-
|
23
|
-
# Iterate through the command line ($*) and put it in the params hash
|
24
|
-
$*.each { |param|
|
25
|
-
key = ( key == true ? false : true ) # Negate the value of key
|
26
|
-
if(key)
|
27
|
-
foo = param
|
28
|
-
else
|
29
|
-
params[foo] = param
|
30
|
-
end
|
31
|
-
}
|
32
|
-
|
33
|
-
# Validate the command line.
|
34
|
-
# Every key should begin with at least one '-' and have a value
|
35
|
-
if( !key ) # If key equals true, then the user should enter one more parameter
|
36
|
-
passed = true
|
37
|
-
params.each { |key, value| # Iterate through all parameters
|
38
|
-
passed = false if(key[0].chr() != '-') # Doesn't it start with a '-'? Not passed...
|
39
|
-
passed = false if(value == '') # I really want a value here, not just an empty string
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
# Return params if check passed, else return -1
|
44
|
-
passed ? params : -1
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
data/extras/config_file
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
#!ruby
|
2
|
-
require 'ftools'
|
3
|
-
require 'tempfile'
|
4
|
-
|
5
|
-
class ConfigFile
|
6
|
-
|
7
|
-
def ConfigFile::parse(filename)
|
8
|
-
# Make sure this file exists and is readable
|
9
|
-
if( FileTest::readable_real?(filename) )
|
10
|
-
new(filename) # Return the class instance
|
11
|
-
else
|
12
|
-
-1 # Return -1 on failure
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(filename)
|
17
|
-
@filename = filename
|
18
|
-
@config = Hash::new() # The class internal variable that holds the config data
|
19
|
-
section = ''
|
20
|
-
|
21
|
-
# Parse the configuration file (and in only TWO rows, God I love Ruby! =)
|
22
|
-
IO::foreach(@filename) { |configLine| @config[section = $1] = Hash::new() if(configLine.gsub(/\s*#.*$/, '') =~ /\s*(\S+)\s*\{/)
|
23
|
-
@config[section].update({$1 => $2}) if(configLine.gsub(/\s*#.*$/, '') =~ /\s*(\S+)\s*=\s*(.*)/) }
|
24
|
-
end
|
25
|
-
|
26
|
-
# Return the requested parameter
|
27
|
-
def getParam(section, parameter)
|
28
|
-
@config[section][parameter] if(@config[section].type == Hash)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Set the provided parameter
|
32
|
-
def setParam(section, parameter, value)
|
33
|
-
# Create a temp file
|
34
|
-
temp = Tempfile::new('config')
|
35
|
-
|
36
|
-
current_section = ''
|
37
|
-
# Loop through the config file
|
38
|
-
IO::foreach(@filename) { |line|
|
39
|
-
current_section = $1 if( line =~ /^\s*(\S+)\s*{\s*(#.*)?$/ ) # Handle the section stuff
|
40
|
-
# Is this a correct parameter entry?
|
41
|
-
if( line =~ /^\s*(\S+)\s*=\s*\S+\s*(#.*)?$/ )
|
42
|
-
|
43
|
-
if( current_section == section && $1 == parameter ) # This is the line we want to change!
|
44
|
-
line.gsub!( /^(\s*\S+\s*=\s*)\S+(\s*(#.*)?)$/, "\\1#{value}\\2" ) # Change the parameter value to the one the user supplied
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
temp.puts(line) # Write the line to the tempfile
|
50
|
-
}
|
51
|
-
|
52
|
-
temp.close() # Close the file
|
53
|
-
File::copy(temp.path, @filename) # Copy the tempfile to overwrite the old one
|
54
|
-
temp.close(true) # Remove the file
|
55
|
-
end
|
56
|
-
|
57
|
-
# Loop through all sections
|
58
|
-
def each_section()
|
59
|
-
@config.each { |key,value| yield(key) }
|
60
|
-
end
|
61
|
-
|
62
|
-
# Loop through all parameters in a section
|
63
|
-
def each_parameter(section)
|
64
|
-
@config[section].each { |key,value| yield(key) }
|
65
|
-
end
|
66
|
-
|
67
|
-
attr_reader :filename
|
68
|
-
|
69
|
-
end
|
data/extras/errorMsg
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#!ruby
|
2
|
-
|
3
|
-
# --- errorMsg ---
|
4
|
-
#
|
5
|
-
# Author: Magnus Engstr�m
|
6
|
-
# Email: magnus@gisab.se
|
7
|
-
# File: errorWrite
|
8
|
-
#
|
9
|
-
# Description
|
10
|
-
# -----------
|
11
|
-
# Outputs an error message to the administrator
|
12
|
-
# ------------------
|
13
|
-
|
14
|
-
def errorMsg(message, exitapp = false)
|
15
|
-
STDERR.puts(message)
|
16
|
-
MP3Control::exit_mpg123() if(exitapp)
|
17
|
-
Kernel::exit(exitapp) if(exitapp) # Terminate application and return the exitapp value if it isn't falsew
|
18
|
-
|
19
|
-
end
|
data/extras/makePlaylist
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
require 'mp3tag'
|
3
|
-
|
4
|
-
def getList(dir)
|
5
|
-
Dir::chdir(dir)
|
6
|
-
|
7
|
-
# Find the files in this directory
|
8
|
-
Dir['*mp3'].each { |file|
|
9
|
-
if(FileTest::file?(file))
|
10
|
-
mp3tag = Mp3Tag::new(Dir::getwd()+"/"+file)
|
11
|
-
if(mp3tag.songname.length > 0)
|
12
|
-
puts("#{Dir::getwd()+"/"+file}||#{mp3tag.songname}||#{mp3tag.artist}||#{mp3tag.album}||#{mp3tag.year}||#{mp3tag.comment}||#{mp3tag.tracknum}||#{mp3tag.genre_id}||#{mp3tag.genre}")
|
13
|
-
else
|
14
|
-
name = Dir::getwd()+"/"+file
|
15
|
-
name =~ /([^\/]+)\.mp3$/
|
16
|
-
puts("#{Dir::getwd()+"/"+file}||#{$1}||#{mp3tag.artist}||#{mp3tag.album}||#{mp3tag.year}||#{mp3tag.comment}||#{mp3tag.tracknum}||#{mp3tag.genre_id}||#{mp3tag.genre}")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
}
|
20
|
-
|
21
|
-
Dir['*'].each { |entry|
|
22
|
-
if(FileTest::directory?(entry))
|
23
|
-
getList(entry)
|
24
|
-
end
|
25
|
-
}
|
26
|
-
Dir::chdir('..')
|
27
|
-
end
|
28
|
-
|
29
|
-
# Change current directory to user supplied one
|
30
|
-
Dir::chdir(ARGV[0])
|
31
|
-
getList(ARGV[0])
|
32
|
-
|
33
|
-
#song = Mp3Tag::new(ARGV[0])
|
34
|
-
#puts song.songname()
|
data/extras/mp3controld
DELETED
@@ -1,289 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
# --- MP3 Control ---
|
4
|
-
#
|
5
|
-
# Author: Magnus Engstr�m
|
6
|
-
# Email: magnus@gisab.se
|
7
|
-
# File: mp3controld
|
8
|
-
#
|
9
|
-
# Description
|
10
|
-
# -----------
|
11
|
-
# An application which manages
|
12
|
-
# mp3 songs on the poor users
|
13
|
-
# computer.
|
14
|
-
# -------------------------
|
15
|
-
|
16
|
-
# --- External files ---
|
17
|
-
# Change directory to find all functions
|
18
|
-
#Dir::chdir("/usr/lib/mp3control")
|
19
|
-
|
20
|
-
load "extras/config_file" # Handles the mp3controld.conf configuration file
|
21
|
-
load "extras/cmdline_parse" # Provides the Commandline::parse which returns an hash of the commandline
|
22
|
-
load "extras/showHelp" # Hmmm... guess what? This function shows the help message =)
|
23
|
-
load "extras/errorMsg" # Outputs error messages to the admin
|
24
|
-
load "extras/playlist" # Core playlist functionality
|
25
|
-
|
26
|
-
# --- MP3Control - the main class ---
|
27
|
-
class MP3Control
|
28
|
-
# --- Core functions ---
|
29
|
-
# initialize() reads the config files and daemonizes!
|
30
|
-
def initialize()
|
31
|
-
# Parse the commandline
|
32
|
-
$commandline = Commandline::parse()
|
33
|
-
|
34
|
-
# Display help if the commandline sucks
|
35
|
-
if($commandline == -1)
|
36
|
-
showHelp()
|
37
|
-
Kernel::exit(-1)
|
38
|
-
end
|
39
|
-
|
40
|
-
# Make this class instance a background daemon
|
41
|
-
daemonize() if($commandline["--daemon"] != 'no' && $commandline["-D"] != 'no')
|
42
|
-
|
43
|
-
# Read the configuration file
|
44
|
-
configfile = ( $commandline["--configfile"] ? $commandline["--configfile"] : 'configuration/mp3controld.conf' ) # Use the --configfile if supplied, else use the default /etc/mp3controld/mp3controld.conf
|
45
|
-
$configFile = ConfigFile::parse(configfile) # Create an new config file object
|
46
|
-
errorMsg("Configuration file #{configfile} isn't readable or doesn't exist!", 137) if($configFile == -1)
|
47
|
-
|
48
|
-
# Find the default playlist (or use the user supplied one from the commandline)
|
49
|
-
defaultPlaylist = $configFile.getParam("programConfig", "defaultPlaylist")
|
50
|
-
defaultPlaylist = $commandline["--playlist"] if($commandline["--playlist"])
|
51
|
-
if( $configFile.getParam(defaultPlaylist, 'listFile').type == String) # Make sure the listFile contains a value
|
52
|
-
if(FileTest.readable_real?( $configFile.getParam(defaultPlaylist, 'listFile') )) # Make sure this file is readable
|
53
|
-
# Cool. Everything looks alright. Lets create a playlist!
|
54
|
-
errorMsg("Loading playlist '#{defaultPlaylist}' from #{$configFile.getParam(defaultPlaylist, 'listFile')}...") if($commandline['--verbose'] == 'on')
|
55
|
-
$current_playlist = Playlist::create_from_file($configFile.getParam(defaultPlaylist, 'listFile'))
|
56
|
-
$current_playlist_name = defaultPlaylist
|
57
|
-
|
58
|
-
# Errorhandling
|
59
|
-
errorMsg("Playlist creation from #{$current_playlist.filename} failed.", 1) if($current_playlist == -1) # Quit and complain if it didn't work
|
60
|
-
errorMsg("Playlist #{defaultPlaylist} (#{$current_playlist.filename}) doesn't contain any entries.", 1) if($current_playlist.length() < 1)
|
61
|
-
errorMsg("Playlist '#{defaultPlaylist}' loaded successfully.") if($commandline["--verbose"] == 'on')
|
62
|
-
|
63
|
-
# Fix wrap/repeat and shuffle the playlist if the configfile says so
|
64
|
-
$current_playlist.wrap = true if($configFile.getParam(defaultPlaylist, 'repeat') == 'true')
|
65
|
-
$current_playlist.shuffle() if($configFile.getParam(defaultPlaylist, 'random') == 'true')
|
66
|
-
$current_playlist.goto(0) # Rewind the playlist
|
67
|
-
else
|
68
|
-
errorMsg("The default playlist doesn't appear to exist, or has the wrong permissions. That's not good.", 1)
|
69
|
-
end
|
70
|
-
else # listFile returns other than string, that's baaaaad
|
71
|
-
errorMsg("the listFile value for '#{defaultPlaylist}' doesn't appear to exist in your #{$configFile.filename}. That's not good.", 1)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Check for the existence of our mpg123 instance
|
75
|
-
errorMsg("Trying to find the mp3 player...") if($commandline["--verbose"] == 'on')
|
76
|
-
@mpg123 = $configFile.getParam('programConfig', 'application') # Get the application name, path, and possible arguments
|
77
|
-
mpg123_application = @mpg123.scan(/^\S+/)
|
78
|
-
if(mpg123_application.type == Array)
|
79
|
-
mpg123_application = mpg123_application[0]
|
80
|
-
else
|
81
|
-
errorMsg("Please check your ProgramConfig/application setting in the configuration file. It seems weird.", 1)
|
82
|
-
end
|
83
|
-
|
84
|
-
# Do some nice errorhandling
|
85
|
-
if( !FileTest::executable_real?(mpg123_application) )
|
86
|
-
errorMsg("#{mpg123_application} doesn't appear to exist. Please do something about it (no, not \"touch #{mpg123_application}\"! Stupid!).", 1)
|
87
|
-
else
|
88
|
-
errorMsg("Found #{mpg123_application}!") if($commandline["--verbose"] == 'on')
|
89
|
-
end
|
90
|
-
|
91
|
-
# Open an instance of mpg123, our high-performance mp3 player
|
92
|
-
@@mpg123 = IO::popen("#{@mpg123} -R -", 'r+')
|
93
|
-
|
94
|
-
# Start all plugins
|
95
|
-
load_plugins()
|
96
|
-
|
97
|
-
# Start the mp3 player
|
98
|
-
mpg123_control()
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
# mpg123_control() gets the input from the mpg123 process and handles it hopefully correctly :)
|
103
|
-
def mpg123_control()
|
104
|
-
|
105
|
-
# Initialize class variables
|
106
|
-
@@stopped = false
|
107
|
-
|
108
|
-
# Start playing if the configfile says so
|
109
|
-
if( $configFile.getParam('programConfig', 'playOnStartup') == 'true' )
|
110
|
-
MP3Control::play()
|
111
|
-
else
|
112
|
-
puts("Dont want to play!")
|
113
|
-
end
|
114
|
-
|
115
|
-
# The infinite 5 second loop =)
|
116
|
-
while(true)
|
117
|
-
begin
|
118
|
-
input = @@mpg123.readline.chop()
|
119
|
-
rescue EOFError
|
120
|
-
errorMsg("mpg123 error! Probably just a file that didn't exist (#{$current_playlist.song_info["filename"]}).")
|
121
|
-
@@mpg123 = IO::popen("#{@mpg123} -R -", 'r+') # Just start it again...
|
122
|
-
MP3Control::next_song() # Next song, so it doesn't die again...
|
123
|
-
end
|
124
|
-
|
125
|
-
# Song stopped
|
126
|
-
MP3Control::next_song() if(input == '@P 0' && @@stopped != true) # Change to the next song if current song stops and the user didn't told it to
|
127
|
-
@@stopped = false if(input == '@P 0' && @@stopped == true) # Reset the stop-flag if the user ordered the stop
|
128
|
-
|
129
|
-
# Time left
|
130
|
-
if(input[0,2] == '@F')
|
131
|
-
input =~ /^@F\s+\S+\s+\S+\s+(\S+)\s+(\S+)$/
|
132
|
-
@@time = $1
|
133
|
-
@@timeleft = $2
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
# start() creates a new instance. Just like .new, but a nicer name.
|
140
|
-
def MP3Control::start()
|
141
|
-
MP3Control::new()
|
142
|
-
end
|
143
|
-
|
144
|
-
# daemonize() daemonizes this process. Cool =)
|
145
|
-
def daemonize()
|
146
|
-
if(child_pid = fork) # Parent code
|
147
|
-
puts("PID #{child_pid}")
|
148
|
-
Kernel::exit(0) # We dont want this parent process any more. Too bad.
|
149
|
-
end
|
150
|
-
|
151
|
-
# Child code. And child wants to be free from parent
|
152
|
-
Process.setsid()
|
153
|
-
end
|
154
|
-
|
155
|
-
# load_plugins() loads all plugins that can be found in the plugins directory
|
156
|
-
def load_plugins()
|
157
|
-
Dir::entries('extras/plugins/').each { |plugin|
|
158
|
-
# Try to load every plugin except all files that begins with a dot
|
159
|
-
if(plugin[0].chr() != '.')
|
160
|
-
retval = 0
|
161
|
-
# Do some errorhandling
|
162
|
-
begin
|
163
|
-
load("extras/plugins/#{plugin}") # Load the files
|
164
|
-
errorMsg("Loaded plugin '#{plugin}'") if($commandline['--verbose'] == 'no')
|
165
|
-
rescue SyntaxError
|
166
|
-
errorMsg("Plugin '#{plugin}' has syntax errors.")
|
167
|
-
end
|
168
|
-
|
169
|
-
# Run the plugin in a separate thread
|
170
|
-
# Try to start the class with the same name as the plugin
|
171
|
-
eval("
|
172
|
-
Thread::new() {
|
173
|
-
start_again = true
|
174
|
-
while(start_again)
|
175
|
-
puts(\"Plugin starting...\")
|
176
|
-
begin
|
177
|
-
retval = #{plugin}::start()
|
178
|
-
rescue
|
179
|
-
error = $!
|
180
|
-
puts(error)
|
181
|
-
puts(error.backtrace)
|
182
|
-
puts(\"Error in plugin #{plugin}! Waiting for 5 seconds before attempting to start again...\")
|
183
|
-
sleep(5)
|
184
|
-
end
|
185
|
-
if(retval == -1)
|
186
|
-
errorMsg(\"Plugin 'plugins/#{plugin}' failed to load...\")
|
187
|
-
start_again = false
|
188
|
-
end
|
189
|
-
end
|
190
|
-
}
|
191
|
-
")
|
192
|
-
|
193
|
-
end
|
194
|
-
}
|
195
|
-
end
|
196
|
-
|
197
|
-
# exit_mpg123() terminates the current mpg123 session
|
198
|
-
def MP3Control::exit_mpg123()
|
199
|
-
#system("kill `pidof mpg123`") # Yes, I know this isn't a nice way to do it in, please fix this and send me a patch :)
|
200
|
-
end
|
201
|
-
|
202
|
-
# mpg123_command() sends a command to mpg123
|
203
|
-
def MP3Control::mpg123_command(command)
|
204
|
-
errorMsg("mpg123 command: '#{command}'") if($commandline['--verbose'] == 'on')
|
205
|
-
@@mpg123.write("#{command}\n")
|
206
|
-
@@mpg123.flush()
|
207
|
-
end
|
208
|
-
|
209
|
-
|
210
|
-
# --- play functions ---
|
211
|
-
# play() plays the current index of the current playlist
|
212
|
-
def MP3Control::play()
|
213
|
-
@@stopped = false
|
214
|
-
mpg123_command("LOAD #{$current_playlist.song_info["filename"]}")
|
215
|
-
end
|
216
|
-
|
217
|
-
# stop() stops playing
|
218
|
-
def MP3Control::stop()
|
219
|
-
mpg123_command("PAUSE")
|
220
|
-
@@stopped = true # Set the stop-status to true
|
221
|
-
end
|
222
|
-
|
223
|
-
# pause() pauses playing
|
224
|
-
def MP3Control::pause()
|
225
|
-
@@stopped = false
|
226
|
-
mpg123_command("PAUSE")
|
227
|
-
end
|
228
|
-
|
229
|
-
# next_song() loads the next song. Yay...
|
230
|
-
def MP3Control::next_song()
|
231
|
-
retval = $current_playlist.next()
|
232
|
-
if(retval == -1)
|
233
|
-
errorMsg("Error while changing to the next song.") # Tell him/her
|
234
|
-
else
|
235
|
-
MP3Control::play() if(@@stopped == false)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
# prev_song() loads the previous song. Yay...
|
240
|
-
def MP3Control::prev_song()
|
241
|
-
retval = $current_playlist.prev()
|
242
|
-
if(retval == -1)
|
243
|
-
errorMsg("Error while changing to the previous song.") # Tell him/her
|
244
|
-
else
|
245
|
-
MP3Control::play() if(@@stopped == false)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
# forward(sec) jumps sec seconds forward
|
250
|
-
def MP3Control::forward(sec)
|
251
|
-
mpg123_command("JUMP +#{sec*38}")
|
252
|
-
end
|
253
|
-
|
254
|
-
# backward(sec) jumps sec seconds backward
|
255
|
-
def MP3Control::backward(sec)
|
256
|
-
mpg123_command("JUMP -#{sec*38}")
|
257
|
-
end
|
258
|
-
|
259
|
-
|
260
|
-
# --- Misc functions ---
|
261
|
-
# getTime() - Get the current song time information. getTime(true) for time left
|
262
|
-
def MP3Control::getTime(whichTime = 'elapsed')
|
263
|
-
case whichTime
|
264
|
-
when 'elapsed'
|
265
|
-
parsed = Time::at(@@time.to_i)
|
266
|
-
when 'left'
|
267
|
-
parsed = Time::at(@@timeleft.to_i)
|
268
|
-
when 'total'
|
269
|
-
parsed = Time::at( (@@time.to_f + @@timeleft.to_f).to_i )
|
270
|
-
end
|
271
|
-
|
272
|
-
hour = (parsed.hour - 1).to_s
|
273
|
-
min = parsed.min.to_s
|
274
|
-
sec = parsed.sec.to_s
|
275
|
-
|
276
|
-
hour = "0#{hour}" if(hour.length == 1)
|
277
|
-
min = "0#{min}" if(min.length == 1)
|
278
|
-
sec = "0#{sec}" if(sec.length == 1)
|
279
|
-
|
280
|
-
hour = (hour == '00' ? '' : "#{hour}:")
|
281
|
-
|
282
|
-
# Return the now formatted time
|
283
|
-
"#{hour}#{min}:#{sec}"
|
284
|
-
end
|
285
|
-
|
286
|
-
end
|
287
|
-
|
288
|
-
# Create an instance of the MP3Control class and start the application
|
289
|
-
MP3Control::start()
|