@thread = nil
@last_poll = nil
@polling = false
-
- self.class.i_am_the_instance self
- end
-
- def buffer
- b, new = BufferManager.spawn_unless_exists("poll for new messages", :hidden => true, :system => true) { PollMode.new }
- b
+ @mode = nil
end
def poll
return if @polling
@polling = true
+ @mode ||= PollMode.new
HookManager.run "before-poll"
BufferManager.flash "Polling for new messages..."
- num, numi, from_and_subj, from_and_subj_inbox = buffer.mode.poll
+ num, numi, from_and_subj, from_and_subj_inbox = @mode.poll
if num > 0
BufferManager.flash "Loaded #{num.pluralize 'new message'}, #{numi} to inbox."
else
begin
yield "Loading from #{source}... " unless source.done? || (source.respond_to?(:has_errors?) && source.has_errors?)
rescue SourceError => e
- Redwood::log "problem getting messages from #{source}: #{e.message}"
+ warn "problem getting messages from #{source}: #{e.message}"
Redwood::report_broken_sources :force_to_top => true
next
end
end
else
yield "Found new message at #{m.source_info} with labels #{m.labels.to_a * ','}"
- Index.add_message m
+ add_new_message m
num += 1
from_and_subj << [m.from && m.from.longname, m.subj]
if (m.labels & [:inbox, :spam, :deleted, :killed]) == Set.new([:inbox])
source.each do |offset, source_labels|
if source.has_errors?
- Redwood::log "error loading messages from #{source}: #{source.error.message}"
+ warn "error loading messages from #{source}: #{source.error.message}"
return
end
yield m
end
rescue SourceError => e
- Redwood::log "problem getting messages from #{source}: #{e.message}"
+ warn "problem getting messages from #{source}: #{e.message}"
Redwood::report_broken_sources :force_to_top => true
end
end