From mboxrd@z Thu Jan 1 00:00:00 1970 From: johannes@antiklimax.com (Johannes Martinsson) Date: Tue, 12 Feb 2008 19:10:27 +0100 Subject: [sup-talk] [PATCH] Changed all (but one) occurrences of redwood to sup. Message-ID: <1202839827-11975-1-git-send-email-johannes@antiklimax.com> * Changed all occurrences of redwood to sup, but left out the one in the FAQ (What are all these "Red...). --- Rakefile | 2 +- bin/sup | 34 ++++++++-------- bin/sup-add | 16 ++++---- bin/sup-config | 18 ++++---- bin/sup-dump | 4 +- bin/sup-recover-sources | 10 ++-- bin/sup-sync | 12 +++--- bin/sup-sync-back | 14 +++--- bin/sup-tweak-labels | 8 ++-- devel/load-index.rb | 2 +- devel/profile.rb | 4 +- devel/start-console.rb | 2 +- doc/FAQ.txt | 2 +- lib/sup.rb | 54 +++++++++++++------------- lib/sup/account.rb | 2 +- lib/sup/buffer.rb | 4 +- lib/sup/colormap.rb | 6 +- lib/sup/contact.rb | 2 +- lib/sup/crypto.rb | 20 +++++----- lib/sup/draft.rb | 4 +- lib/sup/hook.rb | 6 +- lib/sup/horizontal-selector.rb | 2 +- lib/sup/imap.rb | 16 ++++---- lib/sup/index.rb | 54 +++++++++++++------------- lib/sup/keymap.rb | 2 +- lib/sup/label.rb | 2 +- lib/sup/logger.rb | 2 +- lib/sup/maildir.rb | 2 +- lib/sup/mbox.rb | 4 +- lib/sup/mbox/loader.rb | 2 +- lib/sup/mbox/ssh-file.rb | 6 +- lib/sup/mbox/ssh-loader.rb | 2 +- lib/sup/message-chunks.rb | 4 +- lib/sup/message.rb | 34 ++++++++-------- lib/sup/mode.rb | 6 +- lib/sup/modes/buffer-list-mode.rb | 2 +- lib/sup/modes/completion-mode.rb | 2 +- lib/sup/modes/compose-mode.rb | 2 +- lib/sup/modes/contact-list-mode.rb | 4 +- lib/sup/modes/edit-message-mode.rb | 8 ++-- lib/sup/modes/file-browser-mode.rb | 2 +- lib/sup/modes/forward-mode.rb | 2 +- lib/sup/modes/help-mode.rb | 2 +- lib/sup/modes/inbox-mode.rb | 2 +- lib/sup/modes/label-list-mode.rb | 4 +- lib/sup/modes/label-search-results-mode.rb | 2 +- lib/sup/modes/line-cursor-mode.rb | 2 +- lib/sup/modes/log-mode.rb | 2 +- lib/sup/modes/person-search-results-mode.rb | 2 +- lib/sup/modes/poll-mode.rb | 2 +- lib/sup/modes/reply-mode.rb | 2 +- lib/sup/modes/resume-mode.rb | 2 +- lib/sup/modes/scroll-mode.rb | 2 +- lib/sup/modes/search-results-mode.rb | 2 +- lib/sup/modes/text-mode.rb | 2 +- lib/sup/modes/thread-index-mode.rb | 6 +- lib/sup/modes/thread-view-mode.rb | 2 +- lib/sup/person.rb | 2 +- lib/sup/poll.rb | 16 ++++---- lib/sup/sent.rb | 4 +- lib/sup/source.rb | 2 +- lib/sup/suicide.rb | 4 +- lib/sup/tagger.rb | 2 +- lib/sup/textfield.rb | 6 +- lib/sup/thread.rb | 2 +- lib/sup/update.rb | 2 +- test/dummy_source.rb | 2 +- test/test_message.rb | 10 ++-- 68 files changed, 237 insertions(+), 237 deletions(-) diff --git a/Rakefile b/Rakefile index f99246f..3940e4d 100644 --- a/Rakefile +++ b/Rakefile @@ -10,7 +10,7 @@ end # thanks to "Mike H" ## allow people who use development versions by running "rake gem" ## and installing the resulting gem it to be able to do this. (gem ## versions must be in dotted-digit notation only). -version = Redwood::VERSION == "git" ? "999" : Redwood::VERSION +version = Sup::VERSION == "git" ? "999" : Sup::VERSION Hoe.new('sup', version) do |p| p.rubyforge_name = 'sup' diff --git a/bin/sup b/bin/sup index 95b0af7..d0e3472 100644 --- a/bin/sup +++ b/bin/sup @@ -9,12 +9,12 @@ require "sup" BIN_VERSION = "git" -unless Redwood::VERSION == BIN_VERSION +unless Sup::VERSION == BIN_VERSION $stderr.puts < e case h.ask("Should I ask that process to kill itself? ") when /^\s*y\s*$/i h.say "Ok, suggesting seppuku..." - FileUtils.touch Redwood::SUICIDE_FN + FileUtils.touch Sup::SUICIDE_FN sleep SuicideManager::DELAY * 2 - FileUtils.rm_f Redwood::SUICIDE_FN + FileUtils.rm_f Sup::SUICIDE_FN h.say "Let's try that again." retry else @@ -110,20 +110,20 @@ EOS end begin - Redwood::start + Sup::start Index.load if(s = Index.source_for DraftManager.source_name) DraftManager.source = s else - Redwood::log "no draft source, auto-adding..." + Sup::log "no draft source, auto-adding..." Index.add_source DraftManager.new_source end if(s = Index.source_for SentManager.source_name) SentManager.source = s else - Redwood::log "no sent mail source, auto-adding..." + Sup::log "no sent mail source, auto-adding..." Index.add_source SentManager.new_source end @@ -191,7 +191,7 @@ begin begin s.connect rescue SourceError => e - Redwood::log "fatal error loading from #{s}: #{e.message}" + Sup::log "fatal error loading from #{s}: #{e.message}" end end end unless $opts[:no_initial_poll] @@ -293,19 +293,19 @@ ensure Index.stop_lock_update_thread end - Redwood::finish + Sup::finish stop_cursing - Redwood::log "stopped cursing" + Sup::log "stopped cursing" if SuicideManager.instantiated? && SuicideManager.die? - Redwood::log "I've been ordered to commit seppuku. I obey!" + Sup::log "I've been ordered to commit seppuku. I obey!" end if $exceptions.empty? - Redwood::log "no fatal errors. good job, william." + Sup::log "no fatal errors. good job, william." Index.save else - Redwood::log "oh crap, an exception" + Sup::log "oh crap, an exception" end Index.unlock diff --git a/bin/sup-add b/bin/sup-add index 50bbb29..b78963f 100644 --- a/bin/sup-add +++ b/bin/sup-add @@ -7,7 +7,7 @@ require 'trollop' require "sup" $opts = Trollop::options do - version "sup-add (sup #{Redwood::VERSION})" + version "sup-add (sup #{Sup::VERSION})" banner < "mbox", :path => fn }] when :maildir $last_fn ||= ENV["MAIL"] @@ -70,7 +70,7 @@ def add_source return if fn.nil? || fn.empty? $last_fn = fn - [Redwood::Maildir.suggest_labels_for(fn), + [Sup::Maildir.suggest_labels_for(fn), { :scheme => "maildir", :path => fn }] when :mboxssh $last_server ||= "localhost" @@ -82,7 +82,7 @@ def add_source return if fn.nil? || fn.empty? $last_fn = fn fn = "/#{fn}" # lame - [Redwood::MBox::SSHLoader.suggest_labels_for(fn), + [Sup::MBox::SSHLoader.suggest_labels_for(fn), { :scheme => "mbox+ssh", :host => srv, :path => fn }] when :imap, :imaps $last_server ||= "localhost" @@ -101,7 +101,7 @@ def add_source else host, port = srv, nil end - [Redwood::IMAP.suggest_labels_for(fn), + [Sup::IMAP.suggest_labels_for(fn), { :scheme => type.to_s, :host => host, :port => port, :path => fn }] end @@ -150,8 +150,8 @@ def add_source end $terminal.wrap_at = :auto -Redwood::start -index = Redwood::Index.new +Sup::start +index = Sup::Index.new index.load_sources say < to recover the index. @@ -21,7 +21,7 @@ No options. EOS end -index = Redwood::Index.new +index = Sup::Index.new index.load (1 ... index.index.reader.max_doc).each do |i| diff --git a/bin/sup-recover-sources b/bin/sup-recover-sources index af39b7d..33b1a65 100644 --- a/bin/sup-recover-sources +++ b/bin/sup-recover-sources @@ -49,7 +49,7 @@ end.parse(ARGV) require "sup" puts "loading index..." -index = Redwood::Index.new +index = Sup::Index.new index.load puts "loaded index of #{index.size} messages" @@ -64,16 +64,16 @@ ARGV.each do |fn| username = $stdin.gets.chomp print "Password for #{fn} (warning: cleartext): " password = $stdin.gets.chomp - Redwood::IMAP.new(fn, username, password, nil, !$opts[:unusual], $opts[:archive]) + Sup::IMAP.new(fn, username, password, nil, !$opts[:unusual], $opts[:archive]) else - Redwood::MBox::Loader.new(fn, nil, !$opts[:unusual], $opts[:archive]) + Sup::MBox::Loader.new(fn, nil, !$opts[:unusual], $opts[:archive]) end source_ids = {} count = 0 source.each do |offset, labels| begin - m = Redwood::Message.new :source => source, :source_info => offset + m = Sup::Message.new :source => source, :source_info => offset docid, entry = index.load_entry_for_id m.id next unless entry #puts "# #{source} #{offset} #{entry[:source_id]}" @@ -81,7 +81,7 @@ ARGV.each do |fn| source_ids[entry[:source_id]] = (source_ids[entry[:source_id]] || 0) + 1 count += 1 break if count == $opts[:scan_num] - rescue Redwood::MessageFormatError => e + rescue Sup::MessageFormatError => e puts "# #{e.message}" end end diff --git a/bin/sup-sync b/bin/sup-sync index 4a05257..9cb44c4 100644 --- a/bin/sup-sync +++ b/bin/sup-sync @@ -26,7 +26,7 @@ def time end opts = Trollop::options do - version "sup-sync (sup #{Redwood::VERSION})" + version "sup-sync (sup #{Sup::VERSION})" banner < e +rescue Sup::FatalSourceError => e $stderr.puts "Sorry, I couldn't communicate with a source: #{e.message}" rescue Exception => e File.open("sup-exception-log.txt", "w") { |f| f.puts e.backtrace } raise ensure - Redwood::finish + Sup::finish index.unlock end diff --git a/bin/sup-sync-back b/bin/sup-sync-back index 57bebbe..8beb614 100644 --- a/bin/sup-sync-back +++ b/bin/sup-sync-back @@ -16,7 +16,7 @@ def die msg end opts = Trollop::options do - version "sup-sync-back (sup #{Redwood::VERSION})" + version "sup-sync-back (sup #{Sup::VERSION})" banner < e File.open("sup-exception-log.txt", "w") { |f| f.puts e.backtrace } raise ensure - Redwood::finish + Sup::finish index.unlock end diff --git a/bin/sup-tweak-labels b/bin/sup-tweak-labels index 21e766c..eba76f7 100644 --- a/bin/sup-tweak-labels +++ b/bin/sup-tweak-labels @@ -25,7 +25,7 @@ def time end opts = Trollop::options do - version "sup-tweak-labels (sup #{Redwood::VERSION})" + version "sup-tweak-labels (sup #{Sup::VERSION})" banner < e raise ensure index.save - Redwood::finish + Sup::finish index.unlock end diff --git a/devel/load-index.rb b/devel/load-index.rb index 858c8b5..8fa5861 100644 --- a/devel/load-index.rb +++ b/devel/load-index.rb @@ -1,7 +1,7 @@ require 'sup' puts "loading index..." - at index = Redwood::Index.new + at index = Sup::Index.new @index.load @i = @index.index puts "loaded index of #{@i.size} messages" diff --git a/devel/profile.rb b/devel/profile.rb index 67b6b08..e2d6b25 100644 --- a/devel/profile.rb +++ b/devel/profile.rb @@ -1,9 +1,9 @@ require 'rubygems' require 'ruby-prof' -require "redwood" +require "sup" result = RubyProf.profile do - Redwood::ThreadSet.new(ARGV.map { |fn| Redwood::MBox::Scanner.new fn }).load_n_threads 100 + Sup::ThreadSet.new(ARGV.map { |fn| Sup::MBox::Scanner.new fn }).load_n_threads 100 end printer = RubyProf::GraphHtmlPrinter.new(result) diff --git a/devel/start-console.rb b/devel/start-console.rb index 2d7de10..ab7224f 100644 --- a/devel/start-console.rb +++ b/devel/start-console.rb @@ -1,5 +1,5 @@ require 'sup' -include Redwood +include Sup start Index.new Index.load diff --git a/doc/FAQ.txt b/doc/FAQ.txt index 3b65330..1ca093e 100644 --- a/doc/FAQ.txt +++ b/doc/FAQ.txt @@ -88,7 +88,7 @@ A: Move the messages from the source to the target using whatever tool states will be lost when you sync the other source. So do them both in one go. -Q: What are all these "Redwood" references I see in the code? +Q: What are all these "sup" references I see in the code? A: That was Sup's original name. (Think pine, elm. Although I was a Mutt user, I couldn't think of a good progression there.) But it was taken by another project on RubyForge, and wasn't that diff --git a/lib/sup.rb b/lib/sup.rb index cec36b6..05ba6c4 100644 --- a/lib/sup.rb +++ b/lib/sup.rb @@ -23,16 +23,16 @@ class Module klass.instance_eval do define_method(:to_yaml_properties) { vars } - define_method(:to_yaml_type) { "!#{Redwood::YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}" } + define_method(:to_yaml_type) { "!#{Sup::YAML_DOMAIN},#{Sup::YAML_DATE}/#{path}" } end - YAML.add_domain_type("#{Redwood::YAML_DOMAIN},#{Redwood::YAML_DATE}", path) do |type, val| + YAML.add_domain_type("#{Sup::YAML_DOMAIN},#{Sup::YAML_DATE}", path) do |type, val| klass.new(*props.map { |p| val[p] }) end end end -module Redwood +module Sup VERSION = "git" BASE_DIR = ENV["SUP_BASE"] || File.join(ENV["HOME"], ".sup") @@ -91,23 +91,23 @@ module Redwood end def start - Redwood::PersonManager.new Redwood::PERSON_FN - Redwood::SentManager.new Redwood::SENT_FN - Redwood::ContactManager.new Redwood::CONTACT_FN - Redwood::LabelManager.new Redwood::LABEL_FN - Redwood::AccountManager.new $config[:accounts] - Redwood::DraftManager.new Redwood::DRAFT_DIR - Redwood::UpdateManager.new - Redwood::PollManager.new - Redwood::SuicideManager.new Redwood::SUICIDE_FN - Redwood::CryptoManager.new + Sup::PersonManager.new Sup::PERSON_FN + Sup::SentManager.new Sup::SENT_FN + Sup::ContactManager.new Sup::CONTACT_FN + Sup::LabelManager.new Sup::LABEL_FN + Sup::AccountManager.new $config[:accounts] + Sup::DraftManager.new Sup::DRAFT_DIR + Sup::UpdateManager.new + Sup::PollManager.new + Sup::SuicideManager.new Sup::SUICIDE_FN + Sup::CryptoManager.new end def finish - Redwood::LabelManager.save if Redwood::LabelManager.instantiated? - Redwood::ContactManager.save if Redwood::ContactManager.instantiated? - Redwood::PersonManager.save if Redwood::PersonManager.instantiated? - Redwood::BufferManager.deinstantiate! if Redwood::BufferManager.instantiated? + Sup::LabelManager.save if Sup::LabelManager.instantiated? + Sup::ContactManager.save if Sup::ContactManager.instantiated? + Sup::PersonManager.save if Sup::PersonManager.instantiated? + Sup::BufferManager.deinstantiate! if Sup::BufferManager.instantiated? end ## not really a good place for this, so I'll just dump it here. @@ -164,8 +164,8 @@ EOM end ## set up default configuration file -if File.exists? Redwood::CONFIG_FN - $config = Redwood::load_yaml_obj Redwood::CONFIG_FN +if File.exists? Sup::CONFIG_FN + $config = Sup::load_yaml_obj Sup::CONFIG_FN else require 'etc' require 'socket' @@ -198,8 +198,8 @@ else :discard_snippets_from_encrypted_messages => false, } begin - FileUtils.mkdir_p Redwood::BASE_DIR - Redwood::save_yaml_obj $config, Redwood::CONFIG_FN + FileUtils.mkdir_p Sup::BASE_DIR + Sup::save_yaml_obj $config, Sup::CONFIG_FN rescue StandardError => e $stderr.puts "warning: #{e.message}" end @@ -211,7 +211,7 @@ require "sup/hook" ## we have to initialize this guy first, because other classes must ## reference it in order to register hooks, and they do that at parse ## time. -Redwood::HookManager.new Redwood::HOOK_DIR +Sup::HookManager.new Sup::HOOK_DIR ## everything we need to get logging working require "sup/buffer" @@ -221,7 +221,7 @@ require "sup/modes/scroll-mode" require "sup/modes/text-mode" require "sup/modes/log-mode" require "sup/logger" -module Redwood +module Sup def log s; Logger.log s; end module_function :log end @@ -229,13 +229,13 @@ end ## determine encoding and character set $encoding = Locale.current.charset if $encoding - Redwood::log "using character set encoding #{$encoding.inspect}" + Sup::log "using character set encoding #{$encoding.inspect}" else - Redwood::log "warning: can't find character set by using locale, defaulting to utf-8" + Sup::log "warning: can't find character set by using locale, defaulting to utf-8" $encoding = "utf-8" end -## now everything else (which can feel free to call Redwood::log at load time) +## now everything else (which can feel free to call Sup::log at load time) require "sup/update" require "sup/suicide" require "sup/message-chunks" @@ -280,5 +280,5 @@ require "sup/sent" $:.each do |base| d = File.join base, "sup/share/modes/" - Redwood::Mode.load_all_modes d if File.directory? d + Sup::Mode.load_all_modes d if File.directory? d end diff --git a/lib/sup/account.rb b/lib/sup/account.rb index f8ac0fc..30a8a31 100644 --- a/lib/sup/account.rb +++ b/lib/sup/account.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class Account < Person attr_accessor :sendmail, :signature diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb index 4374fa8..6fa659f 100644 --- a/lib/sup/buffer.rb +++ b/lib/sup/buffer.rb @@ -46,7 +46,7 @@ module Ncurses end end -module Redwood +module Sup class InputSequenceAborted < StandardError; end @@ -713,7 +713,7 @@ private end def default_terminal_title buf - "Sup #{Redwood::VERSION} :: #{buf.title}" + "Sup #{Sup::VERSION} :: #{buf.title}" end def get_status_and_title buf diff --git a/lib/sup/colormap.rb b/lib/sup/colormap.rb index 9c6869a..941de40 100644 --- a/lib/sup/colormap.rb +++ b/lib/sup/colormap.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class Colormap @@instance = nil @@ -86,7 +86,7 @@ class Colormap @next_id = (@next_id + 1) % NUM_COLORS @next_id += 1 if @next_id == 0 # 0 is always white on black id = @next_id - Redwood::log "colormap: for color #{sym}, using id #{id} -> #{fg}, #{bg}" + Sup::log "colormap: for color #{sym}, using id #{id} -> #{fg}, #{bg}" Curses.init_pair id, fg, bg or raise ArgumentError, "couldn't initialize curses color pair #{fg}, #{bg} (key #{id})" @@ -94,7 +94,7 @@ class Colormap ## delete the old mapping, if it exists if @users[cp] @users[cp].each do |usym| - Redwood::log "dropping color #{usym} (#{id})" + Sup::log "dropping color #{usym} (#{id})" @entries[usym][3] = nil end @users[cp] = [] diff --git a/lib/sup/contact.rb b/lib/sup/contact.rb index 8050c06..8bea99d 100644 --- a/lib/sup/contact.rb +++ b/lib/sup/contact.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class ContactManager include Singleton diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb index 9e16132..82174bd 100644 --- a/lib/sup/crypto.rb +++ b/lib/sup/crypto.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class CryptoManager include Singleton @@ -20,10 +20,10 @@ class CryptoManager @cmd = case bin when /\S/ - Redwood::log "crypto: detected gpg binary in #{bin}" + Sup::log "crypto: detected gpg binary in #{bin}" "#{bin} --quiet --batch --no-verbose --logger-fd 1 --use-agent" else - Redwood::log "crypto: no gpg binary detected" + Sup::log "crypto: no gpg binary detected" nil end end @@ -31,7 +31,7 @@ class CryptoManager def have_crypto?; !@cmd.nil? end def sign from, to, payload - payload_fn = Tempfile.new "redwood.payload" + payload_fn = Tempfile.new "sup.payload" payload_fn.write format_payload(payload) payload_fn.close @@ -49,7 +49,7 @@ class CryptoManager end def encrypt from, to, payload, sign=false - payload_fn = Tempfile.new "redwood.payload" + payload_fn = Tempfile.new "sup.payload" payload_fn.write format_payload(payload) payload_fn.close @@ -83,11 +83,11 @@ class CryptoManager def verify payload, signature # both RubyMail::Message objects return unknown_status(cant_find_binary) unless @cmd - payload_fn = Tempfile.new "redwood.payload" + payload_fn = Tempfile.new "sup.payload" payload_fn.write format_payload(payload) payload_fn.close - signature_fn = Tempfile.new "redwood.signature" + signature_fn = Tempfile.new "sup.signature" signature_fn.write signature.decode signature_fn.close @@ -109,7 +109,7 @@ class CryptoManager def decrypt payload # a RubyMail::Message object return unknown_status(cant_find_binary) unless @cmd - payload_fn = Tempfile.new "redwood.payload" + payload_fn = Tempfile.new "sup.payload" payload_fn.write payload.to_s payload_fn.close @@ -156,9 +156,9 @@ private def run_gpg args cmd = "#{@cmd} #{args} 2> /dev/null" - #Redwood::log "crypto: running: #{cmd}" + #Sup::log "crypto: running: #{cmd}" output = `#{cmd}` - #Redwood::log "crypto: output: #{output.inspect}" unless $?.success? + #Sup::log "crypto: output: #{output.inspect}" unless $?.success? output end end diff --git a/lib/sup/draft.rb b/lib/sup/draft.rb index 81c0044..87af878 100644 --- a/lib/sup/draft.rb +++ b/lib/sup/draft.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class DraftManager include Singleton @@ -45,7 +45,7 @@ class DraftLoader < Source yaml_properties :cur_offset def initialize cur_offset=0 - dir = Redwood::DRAFT_DIR + dir = Sup::DRAFT_DIR Dir.mkdir dir unless File.exists? dir super DraftManager.source_name, cur_offset, true, false @dir = dir diff --git a/lib/sup/hook.rb b/lib/sup/hook.rb index 98fcf57..c3f018e 100644 --- a/lib/sup/hook.rb +++ b/lib/sup/hook.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class HookManager ## there's probably a better way to do this, but to evaluate a hook @@ -40,7 +40,7 @@ class HookManager end def log s - Redwood::log "hook[#@__name]: #{s}" + Sup::log "hook[#@__name]: #{s}" end def ask_yes_or_no q @@ -137,7 +137,7 @@ private end def log m - Redwood::log("hook: " + m) + Sup::log("hook: " + m) end end diff --git a/lib/sup/horizontal-selector.rb b/lib/sup/horizontal-selector.rb index aef16d4..5d09321 100644 --- a/lib/sup/horizontal-selector.rb +++ b/lib/sup/horizontal-selector.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class HorizontalSelector attr_accessor :label diff --git a/lib/sup/imap.rb b/lib/sup/imap.rb index e785597..b21cebc 100644 --- a/lib/sup/imap.rb +++ b/lib/sup/imap.rb @@ -41,7 +41,7 @@ require 'cgi' ## ## fuck you, imap committee. you managed to design something nearly as ## shitty as mbox but goddamn THIRTY YEARS LATER. -module Redwood +module Sup class IMAP < Source SCAN_INTERVAL = 60 # seconds @@ -131,13 +131,13 @@ class IMAP < Source return if last_id == @ids.length range = (@ids.length + 1) .. last_id - Redwood::log "fetching IMAP headers #{range}" + Sup::log "fetching IMAP headers #{range}" fetch(range, ['RFC822.SIZE', 'INTERNALDATE', 'FLAGS']).each do |v| id = make_id v @ids << id @imap_state[id] = { :id => v.seqno, :flags => v.attr["FLAGS"] } end - Redwood::log "done fetching IMAP headers" + Sup::log "done fetching IMAP headers" end synchronized :scan_mailbox @@ -196,7 +196,7 @@ private if good_results.empty? raise FatalSourceError, "no IMAP response for #{ids} containing all fields #{fields.join(', ')} (got #{results.size} results)" elsif good_results.size < results.size - Redwood::log "Your IMAP server sucks. It sent #{results.size} results for a request for #{good_results.size} messages. What are you using, Binc?" + Sup::log "Your IMAP server sucks. It sent #{results.size} results for a request for #{good_results.size} messages. What are you using, Binc?" end good_results @@ -224,12 +224,12 @@ private raise Net::IMAP::NoResponseError unless @imap.capability().member? "AUTH=CRAM-MD5" @imap.authenticate 'CRAM-MD5', @username, @password rescue Net::IMAP::BadResponseError, Net::IMAP::NoResponseError => e - Redwood::log "CRAM-MD5 authentication failed: #{e.class}. Trying LOGIN auth..." + Sup::log "CRAM-MD5 authentication failed: #{e.class}. Trying LOGIN auth..." begin raise Net::IMAP::NoResponseError unless @imap.capability().member? "AUTH=LOGIN" @imap.authenticate 'LOGIN', @username, @password rescue Net::IMAP::BadResponseError, Net::IMAP::NoResponseError => e - Redwood::log "LOGIN authentication failed: #{e.class}. Trying plain-text LOGIN..." + Sup::log "LOGIN authentication failed: #{e.class}. Trying plain-text LOGIN..." @imap.login @username, @password end end @@ -246,7 +246,7 @@ private def say s @say_id = BufferManager.say s, @say_id if BufferManager.instantiated? - Redwood::log s + Sup::log s end def shutup @@ -303,7 +303,7 @@ private rescue *RECOVERABLE_ERRORS => e if (retries += 1) <= 3 @imap = nil - Redwood::log "got #{e.class.name}: #{e.message.inspect}" + Sup::log "got #{e.class.name}: #{e.message.inspect}" sleep 2 retry end diff --git a/lib/sup/index.rb b/lib/sup/index.rb index cf2ac6d..b634b63 100644 --- a/lib/sup/index.rb +++ b/lib/sup/index.rb @@ -1,4 +1,4 @@ -## the index structure for redwood. interacts with ferret. +## the index structure for sup. interacts with ferret. require 'fileutils' require 'ferret' @@ -6,11 +6,11 @@ begin require 'chronic' $have_chronic = true rescue LoadError => e - Redwood::log "optional 'chronic' library not found (run 'gem install chronic' to install)" + Sup::log "optional 'chronic' library not found (run 'gem install chronic' to install)" $have_chronic = false end -module Redwood +module Sup class Index class LockError < StandardError @@ -44,7 +44,7 @@ class Index def lockfile; File.join @dir, "lock" end def lock - Redwood::log "locking #{lockfile}..." + Sup::log "locking #{lockfile}..." begin @lock.lock rescue Lockfile::MaxTriesLockError @@ -53,7 +53,7 @@ class Index end def start_lock_update_thread - @lock_update_thread = Redwood::reporting_thread("lock update") do + @lock_update_thread = Sup::reporting_thread("lock update") do while true sleep 30 @lock.touch_yourself @@ -99,7 +99,7 @@ EOS def unlock if @lock && @lock.locked? - Redwood::log "unlocking #{lockfile}..." + Sup::log "unlocking #{lockfile}..." @lock.unlock end end @@ -110,7 +110,7 @@ EOS end def save - Redwood::log "saving index and sources..." + Sup::log "saving index and sources..." FileUtils.mkdir_p @dir unless File.exists? @dir save_sources save_index @@ -131,11 +131,11 @@ EOS def load_index dir=File.join(@dir, "ferret") if File.exists? dir - Redwood::log "loading index..." + Sup::log "loading index..." @index = Ferret::Index::Index.new(:path => dir, :analyzer => @analyzer) - Redwood::log "loaded index of #{@index.size} messages" + Sup::log "loaded index of #{@index.size} messages" else - Redwood::log "creating index..." + Sup::log "creating index..." field_infos = Ferret::Index::FieldInfos.new :store => :yes field_infos.add_field :message_id field_infos.add_field :source_id @@ -220,7 +220,7 @@ EOS offset = 0 while true results = @index.search(query, :sort => "date DESC", :limit => EACH_BY_DATE_NUM, :offset => offset) - Redwood::log "got #{results.total_hits} results for query (offset #{offset}) #{query.inspect}" + Sup::log "got #{results.total_hits} results for query (offset #{offset}) #{query.inspect}" results.hits.each { |hit| yield @index[hit.doc][:message_id], lambda { build_message hit.doc } } break if offset >= results.total_hits - EACH_BY_DATE_NUM offset += EACH_BY_DATE_NUM @@ -245,7 +245,7 @@ EOS SAME_SUBJECT_DATE_LIMIT = 7 MAX_CLAUSES = 1000 def each_message_in_thread_for m, opts={} - #Redwood::log "Building thread for #{m.id}: #{m.subj}" + #Sup::log "Building thread for #{m.id}: #{m.subj}" messages = {} searched = {} num_queries = 0 @@ -265,7 +265,7 @@ EOS q = build_query :qobj => q pending = @index.search(q).hits.map { |hit| @index[hit.doc][:message_id] } - Redwood::log "found #{pending.size} results for subject query #{q}" + Sup::log "found #{pending.size} results for subject query #{q}" else pending = [m.id] end @@ -295,7 +295,7 @@ EOS end mid = @index[docid][:message_id] unless messages.member?(mid) - #Redwood::log "got #{mid} as a child of #{id}" + #Sup::log "got #{mid} as a child of #{id}" messages[mid] ||= lambda { build_message docid } refs = @index[docid][:refs].split(" ") pending += refs.select { |id| !searched[id] } @@ -304,10 +304,10 @@ EOS end if killed - Redwood::log "thread for #{m.id} is killed, ignoring" + Sup::log "thread for #{m.id} is killed, ignoring" false else - Redwood::log "ran #{num_queries} queries to build thread of #{messages.size + 1} messages for #{m.id}: #{m.subj}" if num_queries > 0 + Sup::log "ran #{num_queries} queries to build thread of #{messages.size + 1} messages for #{m.id}: #{m.subj}" if num_queries > 0 messages.each { |mid, builder| yield mid, builder } true end @@ -357,12 +357,12 @@ EOS end q.add_query Ferret::Search::TermQuery.new(:label, "spam"), :must_not - Redwood::log "contact search: #{q}" + Sup::log "contact search: #{q}" contacts = {} num = h[:num] || 20 @index.search_each(q, :sort => "date DESC", :limit => :all) do |docid, score| break if contacts.size >= num - #Redwood::log "got message #{docid} to: #{@index[docid][:to].inspect} and from: #{@index[docid][:from].inspect}" + #Sup::log "got message #{docid} to: #{@index[docid][:to].inspect} and from: #{@index[docid][:from].inspect}" f = @index[docid][:from] t = @index[docid][:to] @@ -376,8 +376,8 @@ EOS contacts.keys.compact end - def load_sources fn=Redwood::SOURCE_FN - source_array = (Redwood::load_yaml_obj(fn) || []).map { |o| Recoverable.new o } + def load_sources fn=Sup::SOURCE_FN + source_array = (Sup::load_yaml_obj(fn) || []).map { |o| Recoverable.new o } @sources = Hash[*(source_array).map { |s| [s.id, s] }.flatten] @sources_dirty = false end @@ -405,7 +405,7 @@ protected ## the string with Ferret, and return the resulting query object. norms = @qparser.parse(s).to_s - Redwood::log "normalized #{s.inspect} to #{norms.inspect}" unless s == norms + Sup::log "normalized #{s.inspect} to #{norms.inspect}" unless s == norms subs = norms.gsub(/\b(to|from):(\S+)\b/) do field, name = $1, $2 @@ -460,13 +460,13 @@ protected if realdate case field when "after" - Redwood::log "chronic: translated #{field}:#{datestr} to #{realdate.end}" + Sup::log "chronic: translated #{field}:#{datestr} to #{realdate.end}" "date:(>= #{sprintf "%012d", realdate.end.to_i})" when "before" - Redwood::log "chronic: translated #{field}:#{datestr} to #{realdate.begin}" + Sup::log "chronic: translated #{field}:#{datestr} to #{realdate.begin}" "date:(<= #{sprintf "%012d", realdate.begin.to_i})" else - Redwood::log "chronic: translated #{field}:#{datestr} to #{realdate}" + Sup::log "chronic: translated #{field}:#{datestr} to #{realdate}" "date:(<= #{sprintf "%012d", realdate.end.to_i}) date:(>= #{sprintf "%012d", realdate.begin.to_i})" end else @@ -477,7 +477,7 @@ protected subs = nil if chronic_failure end - Redwood::log "translated #{norms.inspect} to #{subs.inspect}" unless subs == norms + Sup::log "translated #{norms.inspect} to #{subs.inspect}" unless subs == norms if subs [@qparser.parse(subs), extraopts] else @@ -505,14 +505,14 @@ protected query end - def save_sources fn=Redwood::SOURCE_FN + def save_sources fn=Sup::SOURCE_FN if @sources_dirty || @sources.any? { |id, s| s.dirty? } bakfn = fn + ".bak" if File.exists? fn File.chmod 0600, fn FileUtils.mv fn, bakfn, :force => true unless File.exists?(bakfn) && File.size(fn) == 0 end - Redwood::save_yaml_obj @sources.values.sort_by { |s| s.id.to_i }, fn, true + Sup::save_yaml_obj @sources.values.sort_by { |s| s.id.to_i }, fn, true File.chmod 0600, fn end @sources_dirty = false diff --git a/lib/sup/keymap.rb b/lib/sup/keymap.rb index 3176415..d05be92 100644 --- a/lib/sup/keymap.rb +++ b/lib/sup/keymap.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class Keymap def initialize diff --git a/lib/sup/label.rb b/lib/sup/label.rb index 4afc0f9..8d689fe 100644 --- a/lib/sup/label.rb +++ b/lib/sup/label.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class LabelManager include Singleton diff --git a/lib/sup/logger.rb b/lib/sup/logger.rb index ebdeebe..6fc60ba 100644 --- a/lib/sup/logger.rb +++ b/lib/sup/logger.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class Logger @@instance = nil diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb index 7b85383..c03f1d5 100644 --- a/lib/sup/maildir.rb +++ b/lib/sup/maildir.rb @@ -1,7 +1,7 @@ require 'rmail' require 'uri' -module Redwood +module Sup ## Maildir doesn't provide an ordered unique id, which is what Sup ## requires to be really useful. So we must maintain, in memory, a diff --git a/lib/sup/mbox.rb b/lib/sup/mbox.rb index 0ce52fe..19302be 100644 --- a/lib/sup/mbox.rb +++ b/lib/sup/mbox.rb @@ -3,7 +3,7 @@ require "sup/mbox/ssh-file" require "sup/mbox/ssh-loader" require "sup/rfc2047" -module Redwood +module Sup ## some utility functions. actually these are not mbox-specific at all ## and should be moved somewhere else. @@ -58,7 +58,7 @@ module MBox begin Rfc2047.decode_to $encoding, v rescue Errno::EINVAL, Iconv::InvalidEncoding, Iconv::IllegalSequence => e - Redwood::log "warning: error decoding RFC 2047 header (#{e.class.name}): #{e.message}" + Sup::log "warning: error decoding RFC 2047 header (#{e.class.name}): #{e.message}" v end end diff --git a/lib/sup/mbox/loader.rb b/lib/sup/mbox/loader.rb index a66d7b9..92220c2 100644 --- a/lib/sup/mbox/loader.rb +++ b/lib/sup/mbox/loader.rb @@ -1,7 +1,7 @@ require 'rmail' require 'uri' -module Redwood +module Sup module MBox class Loader < Source diff --git a/lib/sup/mbox/ssh-file.rb b/lib/sup/mbox/ssh-file.rb index d474636..ca87d63 100644 --- a/lib/sup/mbox/ssh-file.rb +++ b/lib/sup/mbox/ssh-file.rb @@ -1,6 +1,6 @@ require 'net/ssh' -module Redwood +module Sup module MBox class SSHFileError < StandardError; end @@ -18,7 +18,7 @@ class SSHFileError < StandardError; end ## debugging TODO: remove me def debug s - Redwood::log s + Sup::log s end module_function :debug @@ -154,7 +154,7 @@ private ## TODO: share this code with imap def say s @say_id = BufferManager.say s, @say_id if BufferManager.instantiated? - Redwood::log s + Sup::log s end def shutup diff --git a/lib/sup/mbox/ssh-loader.rb b/lib/sup/mbox/ssh-loader.rb index e422a48..f4c163c 100644 --- a/lib/sup/mbox/ssh-loader.rb +++ b/lib/sup/mbox/ssh-loader.rb @@ -1,6 +1,6 @@ require 'net/ssh' -module Redwood +module Sup module MBox class SSHLoader < Source diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb index 0606395..9bbad7d 100644 --- a/lib/sup/message-chunks.rb +++ b/lib/sup/message-chunks.rb @@ -39,7 +39,7 @@ class Tempfile end -module Redwood +module Sup module Chunk class Attachment HookManager.register "mime-decode", < e - Redwood::log "problem getting messages from #{@source}: #{e.message}" + Sup::log "problem getting messages from #{@source}: #{e.message}" ## we need force_to_top here otherwise this window will cover ## up the error message one @source.error ||= e - Redwood::report_broken_sources :force_to_top => true + Sup::report_broken_sources :force_to_top => true [Chunk::Text.new(error_message(e.message).split("\n"))] end end @@ -234,9 +234,9 @@ EOS begin yield rescue SourceError => e - Redwood::log "problem getting messages from #{@source}: #{e.message}" + Sup::log "problem getting messages from #{@source}: #{e.message}" @source.error ||= e - Redwood::report_broken_sources :force_to_top => true + Sup::report_broken_sources :force_to_top => true error_message e.message end end @@ -307,25 +307,25 @@ private def multipart_signed_to_chunks m if m.body.size != 2 - Redwood::log "warning: multipart/signed with #{m.body.size} parts (expecting 2)" + Sup::log "warning: multipart/signed with #{m.body.size} parts (expecting 2)" return end payload, signature = m.body if signature.multipart? - Redwood::log "warning: multipart/signed with payload multipart #{payload.multipart?} and signature multipart #{signature.multipart?}" + Sup::log "warning: multipart/signed with payload multipart #{payload.multipart?} and signature multipart #{signature.multipart?}" return end ## this probably will never happen if payload.header.content_type == "application/pgp-signature" - Redwood::log "warning: multipart/signed with payload content type #{payload.header.content_type}" + Sup::log "warning: multipart/signed with payload content type #{payload.header.content_type}" return end if signature.header.content_type != "application/pgp-signature" ## unknown signature type; just ignore. - #Redwood::log "warning: multipart/signed with signature content type #{signature.header.content_type}" + #Sup::log "warning: multipart/signed with signature content type #{signature.header.content_type}" return end @@ -334,23 +334,23 @@ private def multipart_encrypted_to_chunks m if m.body.size != 2 - Redwood::log "warning: multipart/encrypted with #{m.body.size} parts (expecting 2)" + Sup::log "warning: multipart/encrypted with #{m.body.size} parts (expecting 2)" return end control, payload = m.body if control.multipart? - Redwood::log "warning: multipart/encrypted with control multipart #{control.multipart?} and payload multipart #{payload.multipart?}" + Sup::log "warning: multipart/encrypted with control multipart #{control.multipart?} and payload multipart #{payload.multipart?}" return end if payload.header.content_type != "application/octet-stream" - Redwood::log "warning: multipart/encrypted with payload content type #{payload.header.content_type}" + Sup::log "warning: multipart/encrypted with payload content type #{payload.header.content_type}" return end if control.header.content_type != "application/pgp-encrypted" - Redwood::log "warning: multipart/encrypted with control content type #{signature.header.content_type}" + Sup::log "warning: multipart/encrypted with control content type #{signature.header.content_type}" return end @@ -421,7 +421,7 @@ private return body unless charset Iconv.iconv($encoding + "//IGNORE", charset, body + " ").join[0 .. -2] rescue Errno::EINVAL, Iconv::InvalidEncoding, Iconv::IllegalSequence, MessageFormatError => e - Redwood::log "warning: error (#{e.class.name}) decoding message body from #{charset}: #{e.message}" + Sup::log "warning: error (#{e.class.name}) decoding message body from #{charset}: #{e.message}" File.open("sup-unable-to-decode.txt", "w") { |f| f.write body } body end diff --git a/lib/sup/mode.rb b/lib/sup/mode.rb index 9900dc3..0808c6b 100644 --- a/lib/sup/mode.rb +++ b/lib/sup/mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class Mode attr_accessor :buffer @@ -91,10 +91,10 @@ EOS unless err.empty? message = err.first.read if message =~ /^\s*$/ - Redwood::log "error running #{command} (but no error message)" + Sup::log "error running #{command} (but no error message)" BufferManager.flash "Error running #{command}!" else - Redwood::log "error running #{command}: #{message}" + Sup::log "error running #{command}: #{message}" BufferManager.flash "Error: #{message}" end return diff --git a/lib/sup/modes/buffer-list-mode.rb b/lib/sup/modes/buffer-list-mode.rb index 91b2fac..e193af7 100644 --- a/lib/sup/modes/buffer-list-mode.rb +++ b/lib/sup/modes/buffer-list-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class BufferListMode < LineCursorMode register_keymap do |k| diff --git a/lib/sup/modes/completion-mode.rb b/lib/sup/modes/completion-mode.rb index 3cb2fad..06cd5dc 100644 --- a/lib/sup/modes/completion-mode.rb +++ b/lib/sup/modes/completion-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class CompletionMode < ScrollMode INTERSTITIAL = " " diff --git a/lib/sup/modes/compose-mode.rb b/lib/sup/modes/compose-mode.rb index f063b92..c3ace01 100644 --- a/lib/sup/modes/compose-mode.rb +++ b/lib/sup/modes/compose-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class ComposeMode < EditMessageMode def initialize opts={} diff --git a/lib/sup/modes/contact-list-mode.rb b/lib/sup/modes/contact-list-mode.rb index f7b3ccb..e5bed77 100644 --- a/lib/sup/modes/contact-list-mode.rb +++ b/lib/sup/modes/contact-list-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup module CanAliasContacts def alias_contact p @@ -98,7 +98,7 @@ class ContactListMode < LineCursorMode end def load_in_background - Redwood::reporting_thread("contact manager load in bg") do + Sup::reporting_thread("contact manager load in bg") do load update BufferManager.draw_screen diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb index 6a7f273..e2e1656 100644 --- a/lib/sup/modes/edit-message-mode.rb +++ b/lib/sup/modes/edit-message-mode.rb @@ -3,7 +3,7 @@ require 'socket' # just for gethostname! require 'pathname' require 'rmail' -module Redwood +module Sup class SendmailCommandFailed < StandardError; end @@ -285,7 +285,7 @@ protected BufferManager.flash "Message sent!" true rescue SystemCallError, SendmailCommandFailed, CryptoManager::Error => e - Redwood::log "Problem sending mail: #{e.message}" + Sup::log "Problem sending mail: #{e.message}" BufferManager.flash "Problem sending mail: #{e.message}" false end @@ -335,7 +335,7 @@ protected end m.header["Date"] = date.rfc2822 m.header["Message-Id"] = @message_id - m.header["User-Agent"] = "Sup/#{Redwood::VERSION}" + m.header["User-Agent"] = "Sup/#{Sup::VERSION}" m end @@ -355,7 +355,7 @@ EOS Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline -User-Agent: Redwood/#{Redwood::VERSION} +User-Agent: Sup/#{Sup::VERSION} EOS end diff --git a/lib/sup/modes/file-browser-mode.rb b/lib/sup/modes/file-browser-mode.rb index b49f3f4..11c7e26 100644 --- a/lib/sup/modes/file-browser-mode.rb +++ b/lib/sup/modes/file-browser-mode.rb @@ -1,6 +1,6 @@ require 'pathname' -module Redwood +module Sup ## meant to be spawned via spawn_modal! class FileBrowserMode < LineCursorMode diff --git a/lib/sup/modes/forward-mode.rb b/lib/sup/modes/forward-mode.rb index 147efb6..3080a6f 100644 --- a/lib/sup/modes/forward-mode.rb +++ b/lib/sup/modes/forward-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class ForwardMode < EditMessageMode ## TODO: share some of this with reply-mode diff --git a/lib/sup/modes/help-mode.rb b/lib/sup/modes/help-mode.rb index b98f131..4244950 100644 --- a/lib/sup/modes/help-mode.rb +++ b/lib/sup/modes/help-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class HelpMode < TextMode def initialize mode, global_keymap diff --git a/lib/sup/modes/inbox-mode.rb b/lib/sup/modes/inbox-mode.rb index a2de13f..e48db6e 100644 --- a/lib/sup/modes/inbox-mode.rb +++ b/lib/sup/modes/inbox-mode.rb @@ -1,6 +1,6 @@ require 'thread' -module Redwood +module Sup class InboxMode < ThreadIndexMode register_keymap do |k| diff --git a/lib/sup/modes/label-list-mode.rb b/lib/sup/modes/label-list-mode.rb index 514e9c4..64221eb 100644 --- a/lib/sup/modes/label-list-mode.rb +++ b/lib/sup/modes/label-list-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class LabelListMode < LineCursorMode register_keymap do |k| @@ -61,7 +61,7 @@ protected @labels = [] counts.map do |label, string, total, unread| if total == 0 && !LabelManager::RESERVED_LABELS.include?(label) - Redwood::log "no hits for label #{label}, deleting" + Sup::log "no hits for label #{label}, deleting" LabelManager.delete label next end diff --git a/lib/sup/modes/label-search-results-mode.rb b/lib/sup/modes/label-search-results-mode.rb index af6831c..6d478d5 100644 --- a/lib/sup/modes/label-search-results-mode.rb +++ b/lib/sup/modes/label-search-results-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class LabelSearchResultsMode < ThreadIndexMode def initialize labels diff --git a/lib/sup/modes/line-cursor-mode.rb b/lib/sup/modes/line-cursor-mode.rb index 246f2b5..51c1cda 100644 --- a/lib/sup/modes/line-cursor-mode.rb +++ b/lib/sup/modes/line-cursor-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup ## extends ScrollMode to have a line-based cursor. class LineCursorMode < ScrollMode diff --git a/lib/sup/modes/log-mode.rb b/lib/sup/modes/log-mode.rb index de16b5e..60f28a8 100644 --- a/lib/sup/modes/log-mode.rb +++ b/lib/sup/modes/log-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class LogMode < TextMode register_keymap do |k| diff --git a/lib/sup/modes/person-search-results-mode.rb b/lib/sup/modes/person-search-results-mode.rb index fc09126..bc46c71 100644 --- a/lib/sup/modes/person-search-results-mode.rb +++ b/lib/sup/modes/person-search-results-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class PersonSearchResultsMode < ThreadIndexMode def initialize people diff --git a/lib/sup/modes/poll-mode.rb b/lib/sup/modes/poll-mode.rb index 5849f3e..0e90643 100644 --- a/lib/sup/modes/poll-mode.rb +++ b/lib/sup/modes/poll-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class PollMode < LogMode def initialize diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb index e7b2929..26549e4 100644 --- a/lib/sup/modes/reply-mode.rb +++ b/lib/sup/modes/reply-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class ReplyMode < EditMessageMode REPLY_TYPES = [:sender, :recipient, :list, :all, :user] diff --git a/lib/sup/modes/resume-mode.rb b/lib/sup/modes/resume-mode.rb index b1c69fc..9f08cfd 100644 --- a/lib/sup/modes/resume-mode.rb +++ b/lib/sup/modes/resume-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class ResumeMode < EditMessageMode def initialize m diff --git a/lib/sup/modes/scroll-mode.rb b/lib/sup/modes/scroll-mode.rb index 219a4ce..d79754a 100644 --- a/lib/sup/modes/scroll-mode.rb +++ b/lib/sup/modes/scroll-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class ScrollMode < Mode ## we define topline and botline as the top and bottom lines of any diff --git a/lib/sup/modes/search-results-mode.rb b/lib/sup/modes/search-results-mode.rb index f64a227..3609762 100644 --- a/lib/sup/modes/search-results-mode.rb +++ b/lib/sup/modes/search-results-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class SearchResultsMode < ThreadIndexMode def initialize qobj, qopts = nil diff --git a/lib/sup/modes/text-mode.rb b/lib/sup/modes/text-mode.rb index 273c028..3ae9935 100644 --- a/lib/sup/modes/text-mode.rb +++ b/lib/sup/modes/text-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class TextMode < ScrollMode attr_reader :text diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb index b13729d..14e1ca6 100644 --- a/lib/sup/modes/thread-index-mode.rb +++ b/lib/sup/modes/thread-index-mode.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup ## subclasses should implement: ## - is_relevant? @@ -79,7 +79,7 @@ EOS def select t=nil, when_done=nil t ||= cursor_thread or return - Redwood::reporting_thread("load messages for thread-view-mode") do + Sup::reporting_thread("load messages for thread-view-mode") do num = t.size message = "Loading #{num.pluralize 'message body'}..." BufferManager.say(message) do |sid| @@ -448,7 +448,7 @@ EOS def load_n_threads_background n=LOAD_MORE_THREAD_NUM, opts={} return if @load_thread # todo: wrap in mutex - @load_thread = Redwood::reporting_thread("load threads for thread-index-mode") do + @load_thread = Sup::reporting_thread("load threads for thread-index-mode") do num = load_n_threads n, opts opts[:when_done].call(num) if opts[:when_done] @load_thread = nil diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb index 961fc5d..766cea5 100644 --- a/lib/sup/modes/thread-view-mode.rb +++ b/lib/sup/modes/thread-view-mode.rb @@ -1,5 +1,5 @@ require 'open3' -module Redwood +module Sup class ThreadViewMode < LineCursorMode ## this holds all info we need to lay out a message diff --git a/lib/sup/person.rb b/lib/sup/person.rb index fb58f23..1995059 100644 --- a/lib/sup/person.rb +++ b/lib/sup/person.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class PersonManager include Singleton diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb index 2dd9150..68f1171 100644 --- a/lib/sup/poll.rb +++ b/lib/sup/poll.rb @@ -1,6 +1,6 @@ require 'thread' -module Redwood +module Sup class PollManager include Singleton @@ -64,7 +64,7 @@ EOS end def start - @thread = Redwood::reporting_thread("periodic poll") do + @thread = Sup::reporting_thread("periodic poll") do while true sleep DELAY / 2 poll if @last_poll.nil? || (Time.now - @last_poll) >= DELAY @@ -88,8 +88,8 @@ EOS begin yield "Loading from #{source}... " unless source.done? || source.has_errors? rescue SourceError => e - Redwood::log "problem getting messages from #{source}: #{e.message}" - Redwood::report_broken_sources :force_to_top => true + Sup::log "problem getting messages from #{source}: #{e.message}" + Sup::report_broken_sources :force_to_top => true next end @@ -140,7 +140,7 @@ EOS source.each do |offset, labels| if source.has_errors? - Redwood::log "error loading messages from #{source}: #{source.error.message}" + Sup::log "error loading messages from #{source}: #{source.error.message}" return end @@ -160,12 +160,12 @@ EOS Index.sync_message m, docid, entry UpdateManager.relay self, :added, m unless entry rescue MessageFormatError => e - Redwood::log "ignoring erroneous message at #{source}##{offset}: #{e.message}" + Sup::log "ignoring erroneous message at #{source}##{offset}: #{e.message}" end end rescue SourceError => e - Redwood::log "problem getting messages from #{source}: #{e.message}" - Redwood::report_broken_sources :force_to_top => true + Sup::log "problem getting messages from #{source}: #{e.message}" + Sup::report_broken_sources :force_to_top => true end end end diff --git a/lib/sup/sent.rb b/lib/sup/sent.rb index 9c802d9..03b9e2a 100644 --- a/lib/sup/sent.rb +++ b/lib/sup/sent.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class SentManager include Singleton @@ -34,7 +34,7 @@ class SentLoader < MBox::Loader yaml_properties :cur_offset def initialize cur_offset=0 - @filename = Redwood::SENT_FN + @filename = Sup::SENT_FN File.open(@filename, "w") { } unless File.exists? @filename super "mbox://" + @filename, cur_offset, true, true end diff --git a/lib/sup/source.rb b/lib/sup/source.rb index 6510aae..e69f816 100644 --- a/lib/sup/source.rb +++ b/lib/sup/source.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class SourceError < StandardError def initialize *a diff --git a/lib/sup/suicide.rb b/lib/sup/suicide.rb index 98b4346..d84a3b9 100644 --- a/lib/sup/suicide.rb +++ b/lib/sup/suicide.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class SuicideManager include Singleton @@ -16,7 +16,7 @@ class SuicideManager bool_reader :die def start - @thread = Redwood::reporting_thread("suicide watch") do + @thread = Sup::reporting_thread("suicide watch") do while true sleep DELAY if File.exists? @fn diff --git a/lib/sup/tagger.rb b/lib/sup/tagger.rb index 3e72463..b8efa8e 100644 --- a/lib/sup/tagger.rb +++ b/lib/sup/tagger.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup class Tagger def initialize mode diff --git a/lib/sup/textfield.rb b/lib/sup/textfield.rb index 2c52595..1c5a751 100644 --- a/lib/sup/textfield.rb +++ b/lib/sup/textfield.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup ## a fully-functional text field supporting completions, expansions, ## history--everything! @@ -112,11 +112,11 @@ class TextField unless @history.empty? value = get_cursed_value @i ||= @history.size - #Redwood::log "history before #{@history.inspect}" + #Sup::log "history before #{@history.inspect}" @history[@i] = value #unless value =~ /^\s*$/ @i = (@i + (c == Ncurses::KEY_UP ? -1 : 1)) % @history.size @value = @history[@i] - #Redwood::log "history after #{@history.inspect}" + #Sup::log "history after #{@history.inspect}" set_cursed_value @value Ncurses::Form::REQ_END_FIELD end diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb index 32002c4..a087e2b 100644 --- a/lib/sup/thread.rb +++ b/lib/sup/thread.rb @@ -24,7 +24,7 @@ ## a faked root object tying them all together into one tree ## structure. -module Redwood +module Sup class Thread include Enumerable diff --git a/lib/sup/update.rb b/lib/sup/update.rb index 021b7e1..e7a9983 100644 --- a/lib/sup/update.rb +++ b/lib/sup/update.rb @@ -1,4 +1,4 @@ -module Redwood +module Sup ## Classic listener/broadcaster paradigm. Handles communication between various ## parts of Sup. diff --git a/test/dummy_source.rb b/test/dummy_source.rb index f3afa31..4e84d31 100644 --- a/test/dummy_source.rb +++ b/test/dummy_source.rb @@ -5,7 +5,7 @@ require 'stringio' require 'rmail' require 'uri' -module Redwood +module Sup class DummySource < Source diff --git a/test/test_message.rb b/test/test_message.rb index c887773..6a3c4a9 100644 --- a/test/test_message.rb +++ b/test/test_message.rb @@ -24,7 +24,7 @@ class File end -module Redwood +module Sup class TestMessage < Test::Unit::TestCase @@ -236,10 +236,10 @@ EOS # the message, then the non-quoted part, then the two attachments assert_equal(4, chunks.length) - assert_equal(chunks[0].class, Redwood::Chunk::Quote) - assert_equal(chunks[1].class, Redwood::Chunk::Text) - assert_equal(chunks[2].class, Redwood::Chunk::Attachment) - assert_equal(chunks[3].class, Redwood::Chunk::Attachment) + assert_equal(chunks[0].class, Sup::Chunk::Quote) + assert_equal(chunks[1].class, Sup::Chunk::Text) + assert_equal(chunks[2].class, Sup::Chunk::Attachment) + assert_equal(chunks[3].class, Sup::Chunk::Attachment) # further testing of chunks will happen in test_message_chunks.rb # (possibly not yet implemented) -- 1.5.3.8