]> gitweb.michael.orlitzky.com - mailshears.git/blob - src/dovecot_mailstore.rb
Implemented get_domain_path and get_account_path in DovecotMailstore.
[mailshears.git] / src / dovecot_mailstore.rb
1 require 'src/filesystem'
2 require 'src/mailstore'
3
4 class DovecotMailstore < Mailstore
5
6 def get_domains_from_filesystem()
7 return Filesystem.get_subdirs(@domain_root)
8 end
9
10
11 def get_accounts_from_filesystem(domains)
12 accounts = []
13
14 domains.each do |domain|
15 domain_path = get_domain_path(domain)
16
17 if File.directory?(domain_path)
18 # If domain_path isn't a directory, maybe the
19 # domain folder doesn't exist? In that case, I
20 # guess we want to report zero accounts.
21 usernames = Filesystem.get_subdirs(domain_path)
22
23 usernames.each do |username|
24 accounts << "#{username}@#{domain}"
25 end
26 end
27 end
28
29 return accounts
30 end
31
32
33 def get_domain_path(domain)
34 # Return the filesystem path for the given domain.
35 # That is, the directory where its mail is stored.
36 domain_path = File.join(@domain_root, domain)
37 return domain_path
38 end
39
40
41 def get_account_path(account)
42 # Return the filesystem path of this account's mailbox.
43 account_parts = account.split('@')
44 user_part = account_parts[0]
45 domain_part = account_parts[1]
46
47 domain_path = get_domain_path(domain_part)
48 account_path = File.join(domain_path, user_part)
49 end
50
51 end