]> git.cworth.org Git - sup/commitdiff
four patches from marcus williams!
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 7 Nov 2007 01:56:27 +0000 (01:56 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 7 Nov 2007 01:56:27 +0000 (01:56 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@673 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/imap.rb
lib/sup/maildir.rb
lib/sup/modes/edit-message-mode.rb
lib/sup/modes/inbox-mode.rb
lib/sup/poll.rb

index c74b0e5bd90fa0cd0df78ceef784641334679983..290ae2a76036652e3b54de28c056b50ae0c1ba4a 100644 (file)
@@ -109,6 +109,10 @@ class IMAP < Source
   def load_message id
     RMail::Parser.read raw_message(id)
   end
+  
+  def each_raw_message_line id
+    StringIO.new(raw_message(id)).each { |l| yield l }
+  end
 
   def raw_header id
     unsynchronized_scan_mailbox
@@ -164,13 +168,14 @@ class IMAP < Source
       id = ids[i]
       state = @mutex.synchronize { @imap_state[id] } or next
       self.cur_offset = id 
-      labels = { :Seen => :unread, 
-                 :Flagged => :starred,
+      labels = { :Flagged => :starred,
                  :Deleted => :deleted
                }.inject(@labels) do |cur, (imap, sup)|
         cur + (state[:flags].include?(imap) ? [sup] : [])
       end
 
+      labels += [:unread] unless state[:flags].include?(:Seen)
+
       yield id, labels
     end
   end
@@ -228,10 +233,12 @@ private
         ## fails with a NO response, the client may try another", in
         ## practice it seems like they can also send a BAD response.
         begin
+          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..."
           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..."
@@ -246,6 +253,8 @@ private
       end
     end.join
 
+
+
     raise exception if exception
   end
 
index 6020c8629c22b82d0637c8ffe494bbd88cd4a461..ba9da001bc60cfbb9537578378e380d7999ea7d4 100644 (file)
@@ -39,6 +39,15 @@ class Maildir < Source
 
     start = @ids.index(cur_offset || start_offset) or raise OutOfSyncSourceError, "Unknown message id #{cur_offset || start_offset}." # couldn't find the most recent email
   end
+  
+  def each_raw_message_line id
+    scan_mailbox
+    with_file_for(id) do |f|
+      until f.eof?
+        yield f.gets
+      end
+    end
+  end
 
   def load_header id
     scan_mailbox
index 3ae0eeb8284f2ac8098f664ac6e4a1662e188f3a..52447e8345e979b5a44bdc89f492efe1e31a14d1 100644 (file)
@@ -127,6 +127,8 @@ protected
     header, @header_lines = format_headers(@header - NON_EDITABLE_HEADERS) + [""]
     @text = header + [""] + @body
     @text += sig_lines unless $config[:edit_signature]
+    
+    @attachment_lines_offset = 0
 
     unless @attachments.empty?
       @text += [""]
index aa40318529144968fe2af078d59b51d42fe566ba..66b7379860ebc875f14a2a461a662074dbaf5c57 100644 (file)
@@ -14,7 +14,9 @@ class InboxMode < ThreadIndexMode
     @@instance = self
   end
 
-  def is_relevant? m; m.has_label? :inbox; end
+  def is_relevant? m
+    m.has_label? :inbox && ([:spam, :deleted, :killed] & m.labels).length == 0
+  end
 
   ## label-list-mode wants to be able to raise us if the user selects
   ## the "inbox" label, so we need to keep our singletonness around
index e124af1ddb2805c3669be30663a8a39fc69af1db..fb7b54608791215660f588091532f92d5c427177 100644 (file)
@@ -153,8 +153,8 @@ EOS
           end
 
           docid, entry = Index.load_entry_for_id m.id
-          m = yield(m, offset, entry) or next
           HookManager.run "before-add-message", :message => m
+          m = yield(m, offset, entry) or next
           Index.sync_message m, docid, entry
           UpdateManager.relay self, :add, m unless entry
         rescue MessageFormatError => e