* [sup-devel] [PATCH] Added support for multiple sent sources.
@ 2010-02-11 8:43 Michael Raitza
2010-02-27 18:46 ` Rich Lane
0 siblings, 1 reply; 2+ messages in thread
From: Michael Raitza @ 2010-02-11 8:43 UTC (permalink / raw)
To: sup-devel
Hi,
I just wondered if it was possible to use several different sources to
store sent mail. After I read the recent posts on the mailing list and
did not find any progress in the HEAD of mainline.git I just implemented
a solution. I took the configuration file based approach. Because of
laziness I think…
Here you are (see also spacefroggs-clone on gitorious):
diff --git a/bin/sup b/bin/sup
index 7824aca..45693b5 100755
--- a/bin/sup
+++ b/bin/sup
@@ -180,10 +180,12 @@ begin
Redwood::SourceManager.add_source DraftManager.new_source
end
- if(s = Redwood::SourceManager.source_for SentManager.source_uri)
- SentManager.source = s
- else
- Redwood::SourceManager.add_source SentManager.default_source
+ Redwood::AccountManager.user_accounts.each do |account|
+ if(s = Redwood::SourceManager.source_for account.sentmanager.source_uri)
+ account.sentmanager.source = s
+ else
+ Redwood::SourceManager.add_source account.sentmanager.default_source
+ end
end
HookManager.run "startup"
diff --git a/bin/sup-config b/bin/sup-config
index bc58a59..4373822 100755
--- a/bin/sup-config
+++ b/bin/sup-config
@@ -207,7 +207,7 @@ say "Only sources capable of storing mail will be listed.\n\n"
Redwood::SourceManager.load_sources
if Redwood::SourceManager.sources.empty?
say "\nUsing the default sup://sent, since you haven't configured other sources yet."
- $config[:sent_source] = 'sup://sent'
+ $config[:accounts][:default][:sent_source] = 'sup://sent'
else
# this handles the event that source.yaml already contains the SentLoader
# source.
@@ -216,11 +216,11 @@ else
choose do |menu|
menu.prompt = "Store my sent mail in? "
- menu.choice('Default (an mbox in ~/.sup, aka sup://sent)') { $config[:sent_source] = 'sup://sent'} unless have_sup_sent
+ menu.choice('Default (an mbox in ~/.sup, aka sup://sent)') { $config[:accounts][:default][:sent_source] = 'sup://sent'} unless have_sup_sent
valid_sents = Redwood::SourceManager.sources.each do |s|
have_sup_sent = true if s.to_s.eql?('sup://sent')
- menu.choice(s.to_s) { $config[:sent_source] = s.to_s } if s.respond_to? :store_message
+ menu.choice(s.to_s) { $config[:accounts][:default][:sent_source] = s.to_s } if s.respond_to? :store_message
end
end
end
diff --git a/lib/sup.rb b/lib/sup.rb
index e03a35d..704be07 100644
--- a/lib/sup.rb
+++ b/lib/sup.rb
@@ -121,7 +121,6 @@ module Redwood
end
def start
- Redwood::SentManager.init $config[:sent_source] || 'sup://sent'
Redwood::ContactManager.init Redwood::CONTACT_FN
Redwood::LabelManager.init Redwood::LABEL_FN
Redwood::AccountManager.init $config[:accounts]
diff --git a/lib/sup/account.rb b/lib/sup/account.rb
index bf8a8a0..c284719 100644
--- a/lib/sup/account.rb
+++ b/lib/sup/account.rb
@@ -1,16 +1,22 @@
module Redwood
class Account < Person
- attr_accessor :sendmail, :signature
+ attr_accessor :sendmail, :signature, :sentmanager
def initialize h
raise ArgumentError, "no name for account" unless h[:name]
raise ArgumentError, "no email for account" unless h[:email]
super h[:name], h[:email]
+
+ @sentmanager = Redwood::SentManager.new h[:sent_source]
@sendmail = h[:sendmail]
@signature = h[:signature]
end
+ def sent_source
+ @sentmanager.source_uri
+ end
+
# Default sendmail command for bouncing mail,
# deduced from #sendmail
def bounce_sendmail
@@ -46,10 +52,12 @@ class AccountManager
def add_account hash, default=false
raise ArgumentError, "no email specified for account" unless hash[:email]
unless default
- [:name, :sendmail, :signature].each { |k| hash[k] ||= @default_account.send(k) }
+ [:name, :sendmail, :signature, :sent_source].each { |k| hash[k] ||= @default_account.send(k) }
end
hash[:alternates] ||= []
+ hash[:sent_source] ||= 'sup://sent'
+
a = Account.new hash
@accounts[a] = true
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index 8849271..7d7618b 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -322,7 +322,7 @@ protected
m = build_message date
IO.popen(acct.sendmail, "w") { |p| p.puts m }
raise SendmailCommandFailed, "Couldn't execute #{acct.sendmail}" unless $? == 0
- SentManager.write_sent_message(date, from_email) { |f| f.puts sanitize_body(m.to_s) }
+ acct.sentmanager.write_sent_message(date, from_email) { |f| f.puts sanitize_body(m.to_s) }
BufferManager.kill_buffer buffer
BufferManager.flash "Message sent!"
true
diff --git a/lib/sup/sent.rb b/lib/sup/sent.rb
index 87ca6c6..1fe398c 100644
--- a/lib/sup/sent.rb
+++ b/lib/sup/sent.rb
@@ -1,7 +1,6 @@
module Redwood
class SentManager
- include Singleton
attr_reader :source, :source_uri
@@ -14,7 +13,7 @@ class SentManager
def source= s
raise FatalSourceError.new("Configured sent_source [#{s.uri}] can't store mail. Correct your configuration.") unless s.respond_to? :store_message
- @souce_uri = s.uri
+ @source_uri = s.uri
@source = s
end
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [sup-devel] [PATCH] Added support for multiple sent sources.
2010-02-11 8:43 [sup-devel] [PATCH] Added support for multiple sent sources Michael Raitza
@ 2010-02-27 18:46 ` Rich Lane
0 siblings, 0 replies; 2+ messages in thread
From: Rich Lane @ 2010-02-27 18:46 UTC (permalink / raw)
To: Michael Raitza; +Cc: sup-devel
I don't see any backwards compatibility code for people who previously
used a different sent source.
I'm not sure there's much of a reason to have a number of SentManager
objects lightly wrapping a source. I'd just store the source directly.
I'd like to keep a tiny SentManager singleton around for its
default_source method.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-02-27 18:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-11 8:43 [sup-devel] [PATCH] Added support for multiple sent sources Michael Raitza
2010-02-27 18:46 ` Rich Lane
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox