3 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
4 # See LICENSE for details.
9 import e2chat, dreamIRCTools, dreamIRCSetup
13 """I am responsible for managing a user's accounts.
15 That is, remembering what accounts are available, their settings,
16 adding and removal of accounts, etc.
18 @ivar accounts: A collection of available accounts.
19 @type accounts: mapping of strings to L{Account<interfaces.IAccount>}s.
21 def __init__(self,session):
22 self.chatui = e2chat.ChatUI()
23 self.config = dreamIRCSetup.dreamIRCConfig()
24 self.accounts = self.config.load()
25 self.pipe = dreamIRCTools.MessagePipe()
27 def startConnect(self):
28 if self.accounts==False:
29 self.pipe.debug("You have defined no valid accounts.")
31 for acct in self.accounts:
32 acct.logOn(self.chatui)
34 def getSnapShot(self):
35 """A snapshot of all the accounts and their status.
37 @returns: A list of tuples, each of the form
38 (string:accountName, boolean:isOnline,
39 boolean:autoLogin, string:gatewayType)
42 for account in self.accounts:
43 data.append((account.accountName, account.isOnline(),account.autoLogin, account.gatewayType))
47 return len(self.accounts) == 0
49 def getConnectionInfo(self):
50 if self.accounts==False:
51 self.pipe.debug("You have defined no valid accounts.")
55 for account in self.accounts:
56 connectioninfo.append(account.isOnline())
59 def addAccount(self, account):
60 self.accounts[account.accountName] = account
62 def delAccount(self, accountName):
63 del self.accounts[accountName]
65 def connect(self, accountName, chatui):
67 @returntype: Deferred L{interfaces.IClient}
69 self.pipe.debug("connecting to : %s" % accountName)
70 return self.accounts[accountName].logOn(chatui)