Ruby/FXRuby Example: ICQ Lite History Browser

[Home] - [Source code] - [Links]

Source code: config.rb

Show file:
| icqlite-history.rb
|-- icq.rb
|-- config.rb

The source below was formatted with rb2html. [view unformatted source]
/home/dan/dev/icqlite-history/icqlitehistorybrowser-0.5/config.rb
  1| # config.rb - the Config module, holding persistent program information
  2| 
  3| module Config
  4| 
  5|   class ConfigDb
  6|     attr_accessor :historydir, :autoresolve, :showtime
  7| 
  8|     def initialize(reg)
  9|       @reg = reg  # initialize Fox registry
 10|       @nicks = {}
 11|     end
 12|       
 13|     def load
 14|       @reg.read
 15|       @historydir = @reg.readStringEntry("config", "historydir", "")
 16|       @autoresolve = @reg.readBoolEntry("config", "autoresolve", true)    
 17|       @showtime = @reg.readBoolEntry("config", "showtime", false)
 18|     end
 19| 
 20|     def store
 21|       # stores persistent information to the Fox registry
 22|       # (usually called on program exit)
 23| 
 24|       @reg.writeStringEntry("config", "historydir", @historydir)
 25|       @reg.writeBoolEntry("config", "autoresolve", @autoresolve)
 26|       @reg.writeBoolEntry("config", "showtime", @showtime)
 27|       
 28|       # remove previously stored nicknames
 29|       @reg.deleteSection("nicks")
 30|       @nicks.each do | uin, nick |
 31| 	# store icq names (where available)
 32| 	@reg.writeStringEntry("nicks", uin, nick)
 33|       end
 34| 
 35|       @reg.write
 36|     end
 37| 
 38|     def getNick(uin)
 39|       # tries to read the nickname for uin from the config file
 40|       # returns "" on failure
 41|       nick = @reg.readStringEntry("nicks", uin, "")
 42|       @nicks[uin] = nick if (nick.length > 0)
 43|       nick
 44|     end
 45| 
 46|     def setNick(uin, nick)
 47|       @nicks[uin] = nick
 48|     end
 49| 
 50|     def clearNicks
 51|       @nicks.clear
 52|     end
 53|   end
 54| 
 55| end
© 2003 Daniel Lichtenberger [personal homepage] | #36271