commit 31301ba4a4b3e78bd48b233f395f2a1779cde98e
parent f81e73683eea8d35eb304f2afdac6397b16b995c
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Thu, 1 Oct 2009 12:54:07 -0400
Merge branch 'poll-unusual' into next
Diffstat:
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/bin/sup b/bin/sup
@@ -76,6 +76,7 @@ global_keymap = Keymap.new do |k|
k.add :search_unread, "Show all unread messages", 'U'
k.add :list_labels, "List labels", 'L'
k.add :poll, "Poll for new messages", 'P'
+ k.add :poll_unusual, "Poll for new messages from unusual sources", '{'
k.add :compose, "Compose new message", 'm', 'c'
k.add :nothing, "Do nothing", :ctrl_g
k.add :recall_draft, "Edit most recent draft message", 'R'
@@ -284,6 +285,10 @@ begin
ComposeMode.spawn_nicely
when :poll
reporting_thread("user-invoked poll") { PollManager.poll }
+ when :poll_unusual
+ if BufferManager.ask_yes_or_no "Really poll unusual sources?"
+ reporting_thread("user-invoked unusual poll") { PollManager.poll_unusual }
+ end
when :recall_draft
case Index.num_results_for :label => :draft
when 0
diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
@@ -35,12 +35,11 @@ EOS
@thread = nil
@last_poll = nil
@polling = false
+ @poll_sources = nil
@mode = nil
end
- def poll
- return if @polling
- @polling = true
+ def poll_with_sources
@mode ||= PollMode.new
HookManager.run "before-poll"
@@ -54,6 +53,22 @@ EOS
HookManager.run "after-poll", :num => num, :num_inbox => numi, :from_and_subj => from_and_subj, :from_and_subj_inbox => from_and_subj_inbox, :num_inbox_total_unread => lambda { Index.num_results_for :labels => [:inbox, :unread] }
+ end
+
+ def poll
+ return if @polling
+ @polling = true
+ @poll_sources = SourceManager.usual_sources
+ num, numi = poll_with_sources
+ @polling = false
+ [num, numi]
+ end
+
+ def poll_unusual
+ return if @polling
+ @polling = true
+ @poll_sources = SourceManager.unusual_sources
+ num, numi = poll_with_sources
@polling = false
[num, numi]
end
@@ -78,7 +93,7 @@ EOS
from_and_subj_inbox = []
@mutex.synchronize do
- SourceManager.usual_sources.each do |source|
+ @poll_sources.each do |source|
# yield "source #{source} is done? #{source.done?} (cur_offset #{source.cur_offset} >= #{source.end_offset})"
begin
yield "Loading from #{source}... " unless source.done? || (source.respond_to?(:has_errors?) && source.has_errors?)
diff --git a/lib/sup/source.rb b/lib/sup/source.rb
@@ -207,6 +207,7 @@ class SourceManager
def source_for uri; sources.find { |s| s.is_source_for? uri }; end
def usual_sources; sources.find_all { |s| s.usual? }; end
+ def unusual_sources; sources.find_all { |s| !s.usual? }; end
def load_sources fn=Redwood::SOURCE_FN
source_array = (Redwood::load_yaml_obj(fn) || []).map { |o| Recoverable.new o }