rwdshell 0.97 → 0.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. data/Readme.txt +6 -0
  2. data/code/01rwdcore/01rwdcore.rb +4 -2
  3. data/code/01rwdcore/test_cases.rb +126 -0
  4. data/code/01rwdcore/test_harness.rb +15 -0
  5. data/code/01rwdcore/uploadreturns.rb +62 -0
  6. data/code/superant.com.rwdtinkerbackwindow/diagnostictab.rb +14 -10
  7. data/configuration/language.dist +1 -1
  8. data/configuration/rwdapplicationidentity.dist +2 -2
  9. data/configuration/rwdshell.dist +2 -2
  10. data/configuration/rwdtinker.dist +2 -2
  11. data/configuration/tinkerwin2variables.dist +1 -1
  12. data/extras/zip/ioextras.rb +114 -0
  13. data/extras/zip/stdrubyext.rb +111 -0
  14. data/extras/zip/tempfile_bugfixed.rb +195 -0
  15. data/extras/zip/zip.rb +1377 -0
  16. data/extras/zip/zipfilesystem.rb +558 -0
  17. data/extras/zip/ziprequire.rb +61 -0
  18. data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/3copyright.rwd +1 -1
  19. data/gui/tinkerbackwindows/superant.com.rwdshellbackwindow/46editscriptrecord.rwd +5 -5
  20. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/70rwddiagnostics.rwd +12 -16
  21. data/init.rb +3 -0
  22. data/rwd_files/HowTo_Shell.txt +4 -0
  23. data/rwd_files/HowTo_Tinker.txt +14 -0
  24. data/rwdconfig.dist +6 -2
  25. data/tests/makedist.rb +16 -1
  26. metadata +12 -17
  27. data/extras/cmdline_parse +0 -47
  28. data/extras/config_file +0 -69
  29. data/extras/errorMsg +0 -19
  30. data/extras/makePlaylist +0 -34
  31. data/extras/mp3controld +0 -289
  32. data/extras/playlist +0 -186
  33. data/extras/showHelp +0 -18
  34. data/gui/helpaboutinstalled/superant.com.rwdwin2helpabout/1appname.rwd +0 -4
  35. data/gui/helpaboutinstalled/superant.com.rwdwin2helpabout/3copyright.rwd +0 -3
  36. data/gui/helpaboutinstalled/superant.com.rwdwin2helpabout/5version.rwd +0 -10
  37. data/installed/rwdtinkerwin2-0.5.inf +0 -8
@@ -193,6 +193,10 @@ http://www.erikveen.dds.nl/rubywebdialogs/index.html
193
193
  Thanks, Steven Gibson
194
194
 
195
195
  == Changelog
196
+ version 0.98
197
+ updated for rwdtinker version 1.61
198
+ add in test harness
199
+
196
200
  version 0.97
197
201
  correct bug in shell command eval
198
202
  beginning to add context help
@@ -227,6 +227,20 @@ http://www.erikveen.dds.nl/rubywebdialogs/index.html
227
227
  Thanks, Steven Gibson
228
228
 
229
229
  == Changelog
230
+ version 1.61
231
+ add in test harness
232
+ rwdtinkerwin2 help about removed
233
+ load main config file in init.rb
234
+
235
+ version 1.60
236
+ add rwdapplication info to diagnostic
237
+ turn rescue on in diagnostic upload
238
+
239
+ version 1.59
240
+ removed rwdtinkerwin2 inf file
241
+ refactored diagnotic page - one button to see all information
242
+ added bug report upload to diagnostic page
243
+
230
244
  version 1.58
231
245
  check for zlib
232
246
  check for files to delete
data/rwdconfig.dist CHANGED
@@ -1,6 +1,10 @@
1
- ##VERSION:1.57
1
+ ##VERSION:1.61
2
2
  # rwdtinker core configuration file
3
3
  ##NAME: ConfigLocation:0
4
4
  ConfigLocation=""
5
5
  ##NAME: ZipsLocation:0
6
- ZipsLocation=""
6
+ ZipsLocation=""
7
+ ##NAME:$testharnessarray:0
8
+ $testharnessarray = ["rwdtinker_all_tests"]
9
+ ##NAME:TestNow:0
10
+ TestNow=false
data/tests/makedist.rb CHANGED
@@ -26,4 +26,19 @@ puts "#{tarcreatecmd}"
26
26
  puts "#{tarcreatecmd2}"
27
27
  `#{tarcreatecmd2}`
28
28
 
29
- print Dir["rwdshell*.{gz,bz2,deb,gem}"]
29
+ gemspecfilename = "rwdshell-#{RwdShellVersion}.gemspec"
30
+ tobject = Time.now
31
+ year = tobject.year.to_s
32
+ month = tobject.mon.to_s
33
+ daydate = tobject.day.to_s
34
+
35
+ fd = File.open(gemspecfilename,"w")
36
+ fd.print("Gem::Specification.new do |s|\n")
37
+ fd.print(" s.name = %q{rwdshell}\n")
38
+ fd.print(" s.version = \"#{RwdShellVersion}\"\n")
39
+ fd.print(" s.date = %q{#{year}-#{month}-#{daydate}}")
40
+ load 'rwdshell/tests/gemspec'
41
+ fd.print($gemspecvar)
42
+ fd.close
43
+
44
+ print Dir["rwdshell*.{gz,bz2,deb,gem}"]
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.6
2
+ rubygems_version: 0.8.8
3
3
  specification_version: 1
4
4
  name: rwdshell
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.97"
7
- date: 2005-03-09
6
+ version: "0.98"
7
+ date: 2005-03-23
8
8
  summary: rwdshell is a GUI front end for operating system commands with rwdtinker and RubyWebDialogs features.
9
9
  require_paths:
10
10
  - "."
@@ -37,6 +37,9 @@ files:
37
37
  - code/01rwdcore/returntomain.rb
38
38
  - code/01rwdcore/rwdtinkerversion.rb
39
39
  - code/01rwdcore/rwdwindowreturn.rb
40
+ - code/01rwdcore/uploadreturns.rb
41
+ - code/01rwdcore/test_cases.rb
42
+ - code/01rwdcore/test_harness.rb
40
43
  - code/superant.com.rwdtinkerbackwindow/controlclient.rb
41
44
  - code/superant.com.rwdtinkerbackwindow/diagnostictab.rb
42
45
  - code/superant.com.rwdtinkerbackwindow/helptexthashtinkerwin2.rb
@@ -88,16 +91,13 @@ files:
88
91
  - configuration/language.dist
89
92
  - configuration/rwdapplicationidentity.dist
90
93
  - configuration/rwdshell.dist
91
- - extras/zip
92
- - extras/cmdline_parse
93
- - extras/config_file
94
- - extras/errorMsg
95
- - extras/makePlaylist
96
- - extras/mp3controld
97
- - extras/playlist
98
- - extras/plugins
99
- - extras/showHelp
100
94
  - extras/rconftool.rb
95
+ - extras/zip/ioextras.rb
96
+ - extras/zip/stdrubyext.rb
97
+ - extras/zip/tempfile_bugfixed.rb
98
+ - extras/zip/zip.rb
99
+ - extras/zip/zipfilesystem.rb
100
+ - extras/zip/ziprequire.rb
101
101
  - scripts/date.sh
102
102
  - scripts/echo2.sh
103
103
  - scripts/lister.sh
@@ -145,12 +145,8 @@ files:
145
145
  - gui/frontwindowz1end/frontwindowend/xx0rwdfirsttab.rwd
146
146
  - gui/helpaboutbegin/superant.com.helpaboutbegin
147
147
  - gui/helpaboutbegin/superant.com.helpaboutbegin/ya0helpscreenstart.rwd
148
- - gui/helpaboutinstalled/superant.com.rwdwin2helpabout
149
148
  - gui/helpaboutinstalled/superant.com.tinkerhelpabout
150
149
  - gui/helpaboutinstalled/superant.com.shellhelpabout
151
- - gui/helpaboutinstalled/superant.com.rwdwin2helpabout/1appname.rwd
152
- - gui/helpaboutinstalled/superant.com.rwdwin2helpabout/3copyright.rwd
153
- - gui/helpaboutinstalled/superant.com.rwdwin2helpabout/5version.rwd
154
150
  - gui/helpaboutinstalled/superant.com.tinkerhelpabout/1appname.rwd
155
151
  - gui/helpaboutinstalled/superant.com.tinkerhelpabout/3copyright.rwd
156
152
  - gui/helpaboutinstalled/superant.com.tinkerhelpabout/5version.rwd
@@ -184,7 +180,6 @@ files:
184
180
  - gui/tinkerbackwindows/superant.com.rwdshellbackwindow/94rwddiagnostics.rwd
185
181
  - gui/tinkerbackwindows/superant.com.rwdshellbackwindow/v9returntab.rwd
186
182
  - gui/zzcoreguiend/tinkerapplicationguiend/yy9rwdend.rwd
187
- - installed/rwdtinkerwin2-0.5.inf
188
183
  - installed/rwdviewlogo-0.4.inf
189
184
  - rwd_files/favicon.ico
190
185
  - rwd_files/HowTo_Tinker.txt
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()