commit 0a33287792fd6650cab5149e78ee9311760f2c64
parent 2b5dacbb74ff91f2a89874c9f67a9c3405d1b775
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Fri, 14 Sep 2007 19:40:22 +0000
yet more minor cryptosig prettynessing
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@576 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
3 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/bin/sup b/bin/sup
@@ -126,8 +126,9 @@ begin
c.add :alternate_patina_color, Ncurses::COLOR_BLACK, Ncurses::COLOR_BLUE
c.add :missing_message_color, Ncurses::COLOR_BLACK, Ncurses::COLOR_RED
c.add :attachment_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK
- c.add :valid_cryptosig_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK, Ncurses::A_BOLD
- c.add :invalid_cryptosig_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_RED, Ncurses::A_BOLD
+ c.add :cryptosig_valid_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK, Ncurses::A_BOLD
+ c.add :cryptosig_unknown_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK
+ c.add :cryptosig_invalid_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_RED, Ncurses::A_BOLD
c.add :quote_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
c.add :sig_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
c.add :quote_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
@@ -123,10 +123,19 @@ EOS
@lines = []
end
- def valid?; status == :valid end
-
def status
- return @status if @status
+ @status, @description = verify unless @status
+ @status
+ end
+
+ def description
+ @status, @description = verify unless @status
+ @description
+ end
+
+private
+
+ def verify
payload = Tempfile.new "redwood.payload"
signature = Tempfile.new "redwood.signature"
@@ -142,14 +151,11 @@ EOS
#Redwood::log "got output: #{gpg_output.inspect}"
@lines = gpg_output.split(/\n/)
- @description =
- if gpg_output =~ /^gpg: (.* signature from .*$)/
- $1
- else
- "Unable to determine validity of cryptographic signature"
- end
-
- @status = ($? == 0 ? :valid : :invalid)
+ if gpg_output =~ /^gpg: (.* signature from .*$)/
+ $? == 0 ? [:valid, $1] : [:invalid, $1]
+ else
+ [:unknown, "Unable to determine validity of cryptographic signature"]
+ end
end
end
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
@@ -511,7 +511,12 @@ private
[[[:sig_patina_color, "#{prefix}- (#{chunk.lines.length}-line signature)"]]] + chunk.lines.map { |line| [[:sig_color, "#{prefix}#{line}"]] }
end
when Message::CryptoSignature
- color = chunk.valid? ? :valid_cryptosig_color : :invalid_cryptosig_color
+ color =
+ case chunk.status
+ when :valid: :cryptosig_valid_color
+ when :invalid: :cryptosig_invalid_color
+ else :cryptosig_unknown_color
+ end
case state
when :closed
[[[color, "#{prefix}+ #{chunk.description}"]]]