DND support
- dnd_action field added darcs-hash:20060122145141-86b55-501a990f765fa66033bdbad9e8da1885a2ef05fe.gz
This commit is contained in:
@@ -131,7 +131,7 @@ class MailComponent(Component):
|
||||
|
||||
field = self.__reg_form.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Free For Chat'", \
|
||||
var = "ffc_action", \
|
||||
var = "chat_action", \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
field.add_option(label = "Do nothing", \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
@@ -163,8 +163,19 @@ class MailComponent(Component):
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Extended Away'", \
|
||||
var = "ea_action", \
|
||||
label = "Action when state is 'Not Available'", \
|
||||
var = "xa_action", \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Do nothing", \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Do not Disturb'", \
|
||||
var = "dnd_action", \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Do nothing", \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
@@ -249,8 +260,8 @@ class MailComponent(Component):
|
||||
|
||||
field = self.__reg_form_init.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Free For Chat'", \
|
||||
var = "ffc_action", \
|
||||
value = str(account.ffc_action))
|
||||
var = "chat_action", \
|
||||
value = str(account.chat_action))
|
||||
field.add_option(label = "Do nothing", \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
@@ -281,9 +292,20 @@ class MailComponent(Component):
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form_init.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Extended Away'", \
|
||||
var = "ea_action", \
|
||||
value = str(account.ea_action))
|
||||
label = "Action when state is 'Not Available'", \
|
||||
var = "xa_action", \
|
||||
value = str(account.xa_action))
|
||||
field.add_option(label = "Do nothing", \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form_init.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Do not Disturb'", \
|
||||
var = "dnd_action", \
|
||||
value = str(account.dnd_action))
|
||||
field.add_option(label = "Do nothing", \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
@@ -312,10 +334,11 @@ class MailComponent(Component):
|
||||
self.__reg_form_init.fields["host"].value = account.host
|
||||
self.__reg_form_init.fields["port"].value = str(account.port)
|
||||
self.__reg_form_init.fields["type"].value = account.get_type()
|
||||
self.__reg_form_init.fields["ffc_action"].value = str(account.ffc_action)
|
||||
self.__reg_form_init.fields["chat_action"].value = str(account.chat_action)
|
||||
self.__reg_form_init.fields["online_action"].value = str(account.online_action)
|
||||
self.__reg_form_init.fields["away_action"].value = str(account.away_action)
|
||||
self.__reg_form_init.fields["ea_action"].value = str(account.ea_action)
|
||||
self.__reg_form_init.fields["xa_action"].value = str(account.xa_action)
|
||||
self.__reg_form_init.fields["dnd_action"].value = str(account.dnd_action)
|
||||
self.__reg_form_init.fields["offline_action"].value = str(account.offline_action)
|
||||
self.__reg_form_init.fields["interval"].value = str(account.interval)
|
||||
|
||||
@@ -549,10 +572,10 @@ class MailComponent(Component):
|
||||
else:
|
||||
port = None
|
||||
|
||||
if x.fields.has_key("ffc_action") and x.fields["ffc_action"].value != "":
|
||||
ffc_action = int(x.fields["ffc_action"].value)
|
||||
if x.fields.has_key("chat_action") and x.fields["chat_action"].value != "":
|
||||
chat_action = int(x.fields["chat_action"].value)
|
||||
else:
|
||||
ffc_action = mailconnection.DO_NOTHING
|
||||
chat_action = mailconnection.DO_NOTHING
|
||||
|
||||
if x.fields.has_key("online_action") and x.fields["online_action"].value != "":
|
||||
online_action = int(x.fields["online_action"].value)
|
||||
@@ -564,10 +587,15 @@ class MailComponent(Component):
|
||||
else:
|
||||
away_action = mailconnection.DO_NOTHING
|
||||
|
||||
if x.fields.has_key("ea_action") and x.fields["ea_action"].value != "":
|
||||
ea_action = int(x.fields["ea_action"].value)
|
||||
if x.fields.has_key("xa_action") and x.fields["xa_action"].value != "":
|
||||
xa_action = int(x.fields["xa_action"].value)
|
||||
else:
|
||||
ea_action = mailconnection.DO_NOTHING
|
||||
xa_action = mailconnection.DO_NOTHING
|
||||
|
||||
if x.fields.has_key("dnd_action") and x.fields["dnd_action"].value != "":
|
||||
dnd_action = int(x.fields["dnd_action"].value)
|
||||
else:
|
||||
dnd_action = mailconnection.DO_NOTHING
|
||||
|
||||
if x.fields.has_key("offline_action") and x.fields["offline_action"].value != "":
|
||||
offline_action = int(x.fields["offline_action"].value)
|
||||
@@ -579,10 +607,10 @@ class MailComponent(Component):
|
||||
else:
|
||||
interval = None
|
||||
|
||||
self.__logger.debug(u"New Account: %s, %s, %s, %s, %s, %s, %s %i %i %i %i %i %i" \
|
||||
self.__logger.debug(u"New Account: %s, %s, %s, %s, %s, %s, %s %i %i %i %i %i %i %i" \
|
||||
% (name, login, password, host, str(port), \
|
||||
mailbox, type, ffc_action, online_action, away_action, \
|
||||
ea_action, offline_action, interval))
|
||||
mailbox, type, chat_action, online_action, away_action, \
|
||||
xa_action, dnd_action, offline_action, interval))
|
||||
|
||||
iq = iq.make_result_response()
|
||||
self.stream.send(iq)
|
||||
@@ -621,10 +649,11 @@ class MailComponent(Component):
|
||||
account.login = login
|
||||
account.password = password
|
||||
account.host = host
|
||||
account.ffc_action = ffc_action
|
||||
account.chat_action = chat_action
|
||||
account.online_action = online_action
|
||||
account.away_action = away_action
|
||||
account.ea_action = ea_action
|
||||
account.xa_action = xa_action
|
||||
account.dnd_action = dnd_action
|
||||
account.offline_action = offline_action
|
||||
account.interval = interval
|
||||
|
||||
@@ -753,48 +782,6 @@ class MailComponent(Component):
|
||||
# self.stream.send(msg)
|
||||
return 1
|
||||
|
||||
# """ Store registered sessions """
|
||||
# def store_registered(self):
|
||||
# self.__logger.debug("STORE_REGISTERED")
|
||||
# try:
|
||||
# if not os.path.isdir(self.__spool_dir):
|
||||
# os.makedirs(self.__spool_dir)
|
||||
# str_registered = anydbm.open(self.__spool_dir + "/registered.db", \
|
||||
# 'n')
|
||||
# self.__logger.debug("Saving registered sessions")
|
||||
# for jid in self.__registered.keys():
|
||||
# for name in self.__registered[jid].keys():
|
||||
# self.__logger.debug("\t" + jid + ", _" + name + "_")
|
||||
# str_registered[jid + '#' + name] = \
|
||||
# str(self.__storage[(jid, name)])
|
||||
# str_registered.close()
|
||||
# except Exception, e:
|
||||
# print >>sys.stderr, "Cannot save to registered.db : "
|
||||
# print >>sys.stderr, e
|
||||
|
||||
# """ Load previously registered sessions """
|
||||
# def load_registered(self):
|
||||
# self.__logger.debug("LOAD_REGISTERED")
|
||||
# try:
|
||||
# if not os.path.isdir(self.__spool_dir):
|
||||
# os.makedirs(self.__spool_dir)
|
||||
# str_registered = anydbm.open(self.__spool_dir + "/registered.db", \
|
||||
# 'c')
|
||||
# self.__logger.debug("Loading previously registered sessions")
|
||||
# for key in str_registered.keys():
|
||||
# jid, name = key.split('#')
|
||||
# if not self.__registered.has_key(jid):
|
||||
# self.__registered[jid] = {}
|
||||
# self.__storage[(jid, name)] = \
|
||||
# mailconnection_factory.str_to_mail_connection(str_registered[key])
|
||||
# # self.__storage[(jid, name)].name = name
|
||||
# self.__logger.debug("Loaded data for %s on %s :" % (jid, name))
|
||||
# self.__logger.debug("\t %s" % (self.__storage[(jid, name)]))
|
||||
# str_registered.close()
|
||||
# except Exception, e:
|
||||
# print >>sys.stderr, "Cannot load registered.db : "
|
||||
# print >>sys.stderr, e
|
||||
|
||||
""" Check mail account """
|
||||
def check_mail(self, jid, name):
|
||||
self.__logger.debug("CHECK_MAIL")
|
||||
|
||||
@@ -151,10 +151,11 @@ class MailConnection(object):
|
||||
self.lastcheck = 0
|
||||
self.status = "offline"
|
||||
self.connection = None
|
||||
self.ffc_action = RETRIEVE
|
||||
self.chat_action = RETRIEVE
|
||||
self.online_action = RETRIEVE
|
||||
self.away_action = RETRIEVE
|
||||
self.ea_action = RETRIEVE
|
||||
self.xa_action = RETRIEVE
|
||||
self.dnd_action = RETRIEVE
|
||||
self.offline_action = DO_NOTHING
|
||||
self.interval = 5
|
||||
|
||||
@@ -165,18 +166,19 @@ class MailConnection(object):
|
||||
and self.host == other.host \
|
||||
and self.port == other.port \
|
||||
and self.ssl == other.ssl \
|
||||
and self.ffc_action == other.ffc_action \
|
||||
and self.chat_action == other.chat_action \
|
||||
and self.online_action == other.online_action \
|
||||
and self.away_action == other.away_action \
|
||||
and self.ea_action == other.ea_action \
|
||||
and self.xa_action == other.xa_action \
|
||||
and self.dnd_action == other.dnd_action \
|
||||
and self.offline_action == other.offline_action \
|
||||
and self.interval == other.interval
|
||||
|
||||
def __str__(self):
|
||||
return self.get_type() + "#" + self.login + "#" + self.password + "#" \
|
||||
+ self.host + "#" + str(self.port) + "#" + str(self.ffc_action) + "#" \
|
||||
+ self.host + "#" + str(self.port) + "#" + str(self.chat_action) + "#" \
|
||||
+ str(self.online_action) + "#" + str(self.away_action) + "#" + \
|
||||
str(self.ea_action) + "#" + str(self.offline_action)
|
||||
str(self.xa_action) + "#" + str(self.dnd_action) + "#" + str(self.offline_action)
|
||||
|
||||
def get_decoded_part(self, part):
|
||||
content_charset = part.get_content_charset()
|
||||
@@ -242,9 +244,10 @@ class MailConnection(object):
|
||||
|
||||
def get_action(self):
|
||||
mapping = {"online": self.online_action,
|
||||
"ffc": self.ffc_action,
|
||||
"chat": self.chat_action,
|
||||
"away": self.away_action,
|
||||
"ea": self.ea_action,
|
||||
"xa": self.xa_action,
|
||||
"dnd": self.dnd_action,
|
||||
"offline": self.offline_action}
|
||||
if mapping.has_key(self.status):
|
||||
return mapping[self.status]
|
||||
|
||||
@@ -62,10 +62,11 @@ def str_to_mail_connection(connection_string):
|
||||
password = arg_list.pop()
|
||||
host = arg_list.pop()
|
||||
port = int(arg_list.pop())
|
||||
ffc_action = int(arg_list.pop())
|
||||
chat_action = int(arg_list.pop())
|
||||
online_action = int(arg_list.pop())
|
||||
away_action = int(arg_list.pop())
|
||||
ea_action = int(arg_list.pop())
|
||||
xa_action = int(arg_list.pop())
|
||||
dnd_action = int(arg_list.pop())
|
||||
offline_action = int(arg_list.pop())
|
||||
result = None
|
||||
if type == "imap":
|
||||
@@ -98,10 +99,11 @@ def str_to_mail_connection(connection_string):
|
||||
ssl = True)
|
||||
if result is None:
|
||||
raise Exception, "Connection type \"" + type + "\" unknown"
|
||||
result.ffc_action = ffc_action
|
||||
result.chat_action = chat_action
|
||||
result.online_action = online_action
|
||||
result.away_action = away_action
|
||||
result.ea_action = ea_action
|
||||
result.xa_action = xa_action
|
||||
result.dnd_action = dnd_action
|
||||
result.offline_action = offline_action
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user