Multilang support
darcs-hash:20060128174218-86b55-4a70de917515e6938b764351be56a81991a5f95b.gz
This commit is contained in:
33
TODO
33
TODO
@@ -1,5 +1,3 @@
|
||||
* Make real documentation
|
||||
|
||||
* i18n support in the same way as ejabberd and
|
||||
PyMSNt, PyICQ-t and PyAIM-t: using xml:lang, but have an option in
|
||||
the config to set the default language to show, when the client do
|
||||
@@ -7,38 +5,17 @@
|
||||
|
||||
* Database backend (default SQLLite)
|
||||
|
||||
* Checkbox and radio button options in the forms to set when and how
|
||||
you like to get the messages (in offline, online, free for chat,
|
||||
away,... presence).
|
||||
So:
|
||||
Online: <radio button for notifications> <radio button for retrieving
|
||||
mails> <checkbox for digest (all new mails in 1 message)>
|
||||
Away: <radio button for notifications> <radio button for retrieving
|
||||
mails> <checkbox for digest (all new mails in 1 message)>
|
||||
Free for Chat: <radio button for notifications> <radio button for
|
||||
retrieving mails> <checkbox for digest (all new mails in 1
|
||||
message)>
|
||||
Extended Away: <radio button for notifications> <radio button for
|
||||
retrieving mails> <checkbox for digest (all new mails in 1
|
||||
message)>
|
||||
Offline: <radio button for notifications> <radio button for
|
||||
retrieving mails> <checkbox for digest (all new mails in 1
|
||||
message)>
|
||||
* Support for attachements with size limit and file format limit
|
||||
(e.g. only png, jpeg,... but no exe, bat,...).
|
||||
|
||||
* Dropdown menu in the forms with configurable time-intervals. E.g.,
|
||||
users can choose betwoon 1 minute, 2 minutes, 5 minutes, 15
|
||||
minutes, 30 minutes, 60 minutes, 1 day. The admin can configure in
|
||||
the configuration file of jmc which options are available.
|
||||
* make JMC run on windows
|
||||
|
||||
* Make real documentation
|
||||
|
||||
* Support for Ad Hoc Commands (see PyMSNt cvs, avatar
|
||||
branch). Interesting for statistics.
|
||||
|
||||
* Support for attachements with size limit and file format limit
|
||||
(e.g. only png, jpeg,... but no exe, bat,...).
|
||||
|
||||
* Support for epoll, kpoll and kqueu (see PyMSNt cvs, avatar branch
|
||||
code).
|
||||
|
||||
* make JMC run on windows
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- coding: UTF-8 -*-
|
||||
##
|
||||
## component.py
|
||||
## Login : David Rousselie <dax@happycoders.org>
|
||||
@@ -43,6 +44,8 @@ from pyxmpp.jid import JID
|
||||
from pyxmpp.jabber.disco import DiscoItems, DiscoItem, DiscoInfo, DiscoIdentity
|
||||
from pyxmpp.jabberd.component import Component
|
||||
|
||||
from jabber.lang import Lang
|
||||
|
||||
class ComponentFatalError(RuntimeError):
|
||||
pass
|
||||
|
||||
@@ -57,6 +60,7 @@ class MailComponent(Component):
|
||||
disco_type = "headline")
|
||||
self.__logger = logging.getLogger("jabber.Component")
|
||||
self.__shutdown = 0
|
||||
self.__default_lang = config.get_content("config/jabber/language")
|
||||
|
||||
# TODO : delete signals not known by Windows
|
||||
signal.signal(signal.SIGINT, self.signal_handler)
|
||||
@@ -77,8 +81,6 @@ class MailComponent(Component):
|
||||
config.get_content("config/jabber/service")
|
||||
self.__storage.spool_dir = self.__spool_dir
|
||||
self.__storage.nb_pk_fields = 2
|
||||
self.__reg_form = None
|
||||
self.__reg_form_init = None
|
||||
# dump registered accounts (save) every hour
|
||||
self.__count = 60
|
||||
self.running = False
|
||||
@@ -86,37 +88,46 @@ class MailComponent(Component):
|
||||
def __del__(self):
|
||||
logging.shutdown()
|
||||
|
||||
""" Register Form creator """
|
||||
def get_reg_form(self):
|
||||
if self.__reg_form == None:
|
||||
self.__reg_form = X()
|
||||
self.__reg_form.xmlns = "jabber:x:data"
|
||||
self.__reg_form.title = "Jabber Mail connection registration"
|
||||
self.__reg_form.instructions = "Enter anything below"
|
||||
self.__reg_form.type = "form"
|
||||
def get_lang(self, node):
|
||||
lang = node.getLang()
|
||||
if lang is None:
|
||||
self.__logger.debug("Using default lang " + self.__default_lang)
|
||||
lang = self.__default_lang
|
||||
return lang
|
||||
|
||||
self.__reg_form.add_field(type = "text-single", \
|
||||
label = "Connection name", \
|
||||
def get_lang_class(self, lang):
|
||||
return getattr(Lang, lang)
|
||||
|
||||
""" Register Form creator """
|
||||
def get_reg_form(self, lang_class):
|
||||
reg_form = X()
|
||||
reg_form.xmlns = "jabber:x:data"
|
||||
reg_form.title = lang_class.register_title
|
||||
reg_form.instructions = lang_class.register_instructions
|
||||
reg_form.type = "form"
|
||||
|
||||
reg_form.add_field(type = "text-single", \
|
||||
label = lang_class.account_name, \
|
||||
var = "name")
|
||||
|
||||
self.__reg_form.add_field(type = "text-single", \
|
||||
label = "Login", \
|
||||
reg_form.add_field(type = "text-single", \
|
||||
label = lang_class.account_login, \
|
||||
var = "login")
|
||||
|
||||
self.__reg_form.add_field(type = "text-private", \
|
||||
label = "Password", \
|
||||
reg_form.add_field(type = "text-private", \
|
||||
label = lang_class.account_password, \
|
||||
var = "password")
|
||||
|
||||
self.__reg_form.add_field(type = "text-single", \
|
||||
label = "Host", \
|
||||
reg_form.add_field(type = "text-single", \
|
||||
label = lang_class.account_host, \
|
||||
var = "host")
|
||||
|
||||
self.__reg_form.add_field(type = "text-single", \
|
||||
label = "Port", \
|
||||
reg_form.add_field(type = "text-single", \
|
||||
label = lang_class.account_port, \
|
||||
var = "port")
|
||||
|
||||
field = self.__reg_form.add_field(type = "list-single", \
|
||||
label = "Mailbox type", \
|
||||
field = reg_form.add_field(type = "list-single", \
|
||||
label = lang_class.account_type, \
|
||||
var = "type")
|
||||
field.add_option(label = "POP3", \
|
||||
value = "pop3")
|
||||
@@ -127,125 +138,124 @@ class MailComponent(Component):
|
||||
field.add_option(label = "IMAPS", \
|
||||
value = "imaps")
|
||||
|
||||
self.__reg_form.add_field(type = "text-single", \
|
||||
label = "Mailbox (IMAP)", \
|
||||
reg_form.add_field(type = "text-single", \
|
||||
label = lang_class.account_mailbox, \
|
||||
var = "mailbox", \
|
||||
value = "INBOX")
|
||||
|
||||
field = self.__reg_form.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Free For Chat'", \
|
||||
field = reg_form.add_field(type = "list-single", \
|
||||
label = lang_class.account_ffc_action, \
|
||||
var = "chat_action", \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Online'", \
|
||||
field = reg_form.add_field(type = "list-single", \
|
||||
label = lang_class.account_online_action, \
|
||||
var = "online_action", \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Away'", \
|
||||
field = reg_form.add_field(type = "list-single", \
|
||||
label = lang_class.account_away_action, \
|
||||
var = "away_action", \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Not Available'", \
|
||||
field = reg_form.add_field(type = "list-single", \
|
||||
label = lang_class.account_xa_action, \
|
||||
var = "xa_action", \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Do not Disturb'", \
|
||||
field = reg_form.add_field(type = "list-single", \
|
||||
label = lang_class.account_dnd_action, \
|
||||
var = "dnd_action", \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Offline'", \
|
||||
field = reg_form.add_field(type = "list-single", \
|
||||
label = lang_class.account_offline_action, \
|
||||
var = "offline_action", \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
# default interval in config file
|
||||
self.__reg_form.add_field(type = "text-single", \
|
||||
label = "Mail check interval (in minutes)", \
|
||||
reg_form.add_field(type = "text-single", \
|
||||
label = lang_class.account_check_interval, \
|
||||
var = "interval", \
|
||||
value = "5")
|
||||
|
||||
return self.__reg_form
|
||||
return reg_form
|
||||
|
||||
""" Register Form modifier for existing accounts """
|
||||
def get_reg_form_init(self, jid, name):
|
||||
def get_reg_form_init(self, lang_class, jid, name):
|
||||
if not self.__storage.has_key((jid, name)):
|
||||
return None
|
||||
account = self.__storage[(jid, name)]
|
||||
if self.__reg_form_init == None:
|
||||
self.__reg_form_init = X()
|
||||
self.__reg_form_init.xmlns = "jabber:x:data"
|
||||
self.__reg_form_init.title = "Jabber mail connection Modifier"
|
||||
self.__reg_form_init.instructions = "Modifier for connection " + \
|
||||
reg_form_init = X()
|
||||
reg_form_init.xmlns = "jabber:x:data"
|
||||
reg_form_init.title = lang_class.update_title
|
||||
reg_form_init.instructions = lang_class.update_instructions + \
|
||||
name
|
||||
self.__reg_form_init.type = "form"
|
||||
reg_form_init.type = "form"
|
||||
|
||||
self.__reg_form_init.add_field(type = "fixed", \
|
||||
label = "Connection name", \
|
||||
reg_form_init.add_field(type = "fixed", \
|
||||
label = lang_class.account_name, \
|
||||
var = "name", \
|
||||
value = name)
|
||||
|
||||
self.__reg_form_init.add_field(type = "text-single", \
|
||||
label = "Login", \
|
||||
reg_form_init.add_field(type = "text-single", \
|
||||
label = lang_class.account_login, \
|
||||
var = "login", \
|
||||
value = account.login)
|
||||
|
||||
self.__reg_form_init.add_field(type = "text-private", \
|
||||
label = "Password", \
|
||||
reg_form_init.add_field(type = "text-private", \
|
||||
label = lang_class.account_password, \
|
||||
var = "password", \
|
||||
value = account.password)
|
||||
|
||||
self.__reg_form_init.add_field(type = "text-single", \
|
||||
label = "Host", \
|
||||
reg_form_init.add_field(type = "text-single", \
|
||||
label = lang_class.account_host, \
|
||||
var = "host", \
|
||||
value = account.host)
|
||||
|
||||
self.__reg_form_init.add_field(type = "text-single", \
|
||||
label = "Port", \
|
||||
reg_form_init.add_field(type = "text-single", \
|
||||
label = lang_class.account_port, \
|
||||
var = "port", \
|
||||
value = str(account.port))
|
||||
value = unicode(account.port))
|
||||
|
||||
field = self.__reg_form_init.add_field(type = "list-single", \
|
||||
label = "Mailbox type", \
|
||||
field = reg_form_init.add_field(type = "list-single", \
|
||||
label = lang_class.account_type, \
|
||||
var = "type", \
|
||||
value = account.get_type())
|
||||
field.add_option(label = "POP3", \
|
||||
@@ -257,100 +267,87 @@ class MailComponent(Component):
|
||||
field.add_option(label = "IMAPS", \
|
||||
value = "imaps")
|
||||
|
||||
self.__reg_form_init.add_field(type = "text-single", \
|
||||
label = "Mailbox (IMAP)", \
|
||||
reg_form_init.add_field(type = "text-single", \
|
||||
label = lang_class.account_mailbox, \
|
||||
var = "mailbox")
|
||||
|
||||
field = self.__reg_form_init.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Free For Chat'", \
|
||||
field = reg_form_init.add_field(type = "list-single", \
|
||||
label = lang_class.account_ffc_action, \
|
||||
var = "chat_action", \
|
||||
value = str(account.chat_action))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form_init.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Online'", \
|
||||
field = reg_form_init.add_field(type = "list-single", \
|
||||
label = lang_class.account_online_action, \
|
||||
var = "online_action", \
|
||||
value = str(account.online_action))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form_init.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Away'", \
|
||||
field = reg_form_init.add_field(type = "list-single", \
|
||||
label = lang_class.account_away_action, \
|
||||
var = "away_action", \
|
||||
value = str(account.away_action))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form_init.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Not Available'", \
|
||||
field = reg_form_init.add_field(type = "list-single", \
|
||||
label = lang_class.account_xa_action, \
|
||||
var = "xa_action", \
|
||||
value = str(account.xa_action))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form_init.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Do not Disturb'", \
|
||||
field = reg_form_init.add_field(type = "list-single", \
|
||||
label = lang_class.account_dnd_action, \
|
||||
var = "dnd_action", \
|
||||
value = str(account.dnd_action))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
field = self.__reg_form_init.add_field(type = "list-single", \
|
||||
label = "Action when state is 'Offline'", \
|
||||
field = reg_form_init.add_field(type = "list-single", \
|
||||
label = lang_class.account_offline_action, \
|
||||
var = "offline_action", \
|
||||
value = str(account.offline_action))
|
||||
field.add_option(label = "Do nothing", \
|
||||
field.add_option(label = lang_class.action_nothing, \
|
||||
value = str(mailconnection.DO_NOTHING))
|
||||
field.add_option(label = "Send mail digest", \
|
||||
field.add_option(label = lang_class.action_digest, \
|
||||
value = str(mailconnection.DIGEST))
|
||||
field.add_option(label = "Retrieve mail", \
|
||||
field.add_option(label = lang_class.action_retrieve, \
|
||||
value = str(mailconnection.RETRIEVE))
|
||||
|
||||
self.__reg_form_init.add_field(type = "text-single", \
|
||||
label = "Mail check interval (in minutes)", \
|
||||
reg_form_init.add_field(type = "text-single", \
|
||||
label = lang_class.account_check_interval, \
|
||||
var = "interval", \
|
||||
value = str(account.interval))
|
||||
else:
|
||||
self.__reg_form_init.fields["login"].value = account.login
|
||||
self.__reg_form_init.fields["password"].value = account.password
|
||||
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["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["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)
|
||||
|
||||
if account.get_type()[0:4] == "imap":
|
||||
self.__reg_form_init.fields["mailbox"].value = account.mailbox
|
||||
reg_form_init.fields["mailbox"].value = account.mailbox
|
||||
else:
|
||||
self.__reg_form_init.fields["mailbox"].value = "INBOX"
|
||||
reg_form_init.fields["mailbox"].value = u"INBOX"
|
||||
|
||||
return self.__reg_form_init
|
||||
return reg_form_init
|
||||
|
||||
""" Looping method """
|
||||
def run(self, timeout):
|
||||
@@ -475,12 +472,13 @@ class MailComponent(Component):
|
||||
""" Discovery get nested nodes handler """
|
||||
def disco_get_items(self, node, iq):
|
||||
self.__logger.debug("DISCO_GET_ITEMS")
|
||||
lang_class = self.get_lang_class(self.get_lang(iq.get_node()))
|
||||
base_from_jid = unicode(iq.get_from().bare())
|
||||
di = DiscoItems()
|
||||
if not node:
|
||||
for name in self.__storage.keys((base_from_jid,)):
|
||||
account = self.__storage[(base_from_jid, name)]
|
||||
str_name = account.get_type() + " connection " + name
|
||||
str_name = account.get_type() + lang_class.connection + name
|
||||
if account.get_type()[0:4] == "imap":
|
||||
str_name += " (" + account.mailbox + ")"
|
||||
DiscoItem(di, JID(name + "@" + unicode(self.jid)), \
|
||||
@@ -500,20 +498,24 @@ class MailComponent(Component):
|
||||
""" Send back register form to user """
|
||||
def get_register(self, iq):
|
||||
self.__logger.debug("GET_REGISTER")
|
||||
lang_class = self.get_lang_class(self.get_lang(iq.get_node()))
|
||||
base_from_jid = unicode(iq.get_from().bare())
|
||||
to = iq.get_to()
|
||||
iq = iq.make_result_response()
|
||||
q = iq.new_query("jabber:iq:register")
|
||||
if to and to != self.jid:
|
||||
self.get_reg_form_init(base_from_jid, to.node).attach_xml(q)
|
||||
self.get_reg_form_init(lang_class,
|
||||
base_from_jid,
|
||||
to.node).attach_xml(q)
|
||||
else:
|
||||
self.get_reg_form().attach_xml(q)
|
||||
self.get_reg_form(lang_class).attach_xml(q)
|
||||
self.stream.send(iq)
|
||||
return 1
|
||||
|
||||
""" Handle user registration response """
|
||||
def set_register(self, iq):
|
||||
self.__logger.debug("SET_REGISTER")
|
||||
lang_class = self.get_lang_class(self.get_lang(iq.get_node()))
|
||||
to = iq.get_to()
|
||||
from_jid = iq.get_from()
|
||||
base_from_jid = unicode(from_jid.bare())
|
||||
@@ -633,15 +635,13 @@ class MailComponent(Component):
|
||||
if self.__storage.has_key((base_from_jid, name)):
|
||||
m = Message(from_jid = self.jid, to_jid = from_jid, \
|
||||
stanza_type = "message", \
|
||||
body = u"Updated %s connection '%s': Registered with "\
|
||||
"username '%s' and password '%s' on '%s'" \
|
||||
body = lang_class.update_account_message \
|
||||
% (type, name, login, password, socket))
|
||||
self.stream.send(m)
|
||||
else:
|
||||
m = Message(from_jid = self.jid, to_jid = from_jid, \
|
||||
stanza_type = "message", \
|
||||
body = u"New %s connection '%s': Registered with " \
|
||||
"username '%s' and password '%s' on '%s'" \
|
||||
body = lang_class.new_account_message \
|
||||
% (type, name, login, password, socket))
|
||||
self.stream.send(m)
|
||||
p = Presence(from_jid = name + "@" + unicode(self.jid), \
|
||||
@@ -836,6 +836,7 @@ class MailComponent(Component):
|
||||
self.stream.send(mesg)
|
||||
account.disconnect()
|
||||
except Exception,e:
|
||||
# TODO : Send error message to the user
|
||||
self.__logger.debug("Error while checking mail : %s" \
|
||||
% (e))
|
||||
|
||||
|
||||
82
jabber/lang.py
Normal file
82
jabber/lang.py
Normal file
@@ -0,0 +1,82 @@
|
||||
##
|
||||
## lang.py
|
||||
## Login : David Rousselie <david.rousselie@happycoders.org>
|
||||
## Started on Sat Jan 28 16:37:11 2006 David Rousselie
|
||||
## $Id$
|
||||
##
|
||||
## Copyright (C) 2006 David Rousselie
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##
|
||||
|
||||
|
||||
class Lang:
|
||||
class en:
|
||||
register_title = u"Jabber Mail connection registration"
|
||||
register_instructions = u"Enter connection parameters"
|
||||
account_name = u"Connection name"
|
||||
account_login = u"Login"
|
||||
account_password = u"Password"
|
||||
account_host = u"Host"
|
||||
account_port = u"Port"
|
||||
account_type = u"Mail serveur type"
|
||||
account_mailbox = u"Mailbox path (IMAP)"
|
||||
account_ffc_action = u"Action when state is 'Free For Chat'"
|
||||
account_online_action = u"Action when state is 'Online'"
|
||||
account_away_action = u"Action when state is 'Away'"
|
||||
account_xa_action = u"Action when state is 'Not Available'"
|
||||
account_dnd_action = u"Action when state is 'Do not Disturb'"
|
||||
account_offline_action = u"Action when state is 'Offline'"
|
||||
account_check_interval = u"Mail check interval (in minutes)"
|
||||
action_nothing = u"Do nothing"
|
||||
action_retrieve = u"Retrieve mail"
|
||||
action_digest = u"Send mail digest"
|
||||
update_title = u"Jabber mail connection update"
|
||||
update_instructions = u"Modifying connection "
|
||||
connection = u" connection "
|
||||
update_account_message = u"Updated %s connection '%s': Registered with "\
|
||||
"username '%s' and password '%s' on '%s'"
|
||||
new_account_message = u"New %s connection '%s': Registered with " \
|
||||
"username '%s' and password '%s' on '%s'"
|
||||
|
||||
class fr:
|
||||
register_title = u"Enregistrement d'une nouvelle connexion à un serveur email."
|
||||
register_instructions = u"Entrer les paramètres de connexion"
|
||||
# TODO
|
||||
account_name = u"Connection name"
|
||||
account_login = u"Login"
|
||||
account_password = u"Password"
|
||||
account_host = u"Host"
|
||||
account_port = u"Port"
|
||||
account_type = u"Mail serveur type"
|
||||
account_mailbox = u"Mailbox path (IMAP)"
|
||||
account_ffc_action = u"Action when state is 'Free For Chat'"
|
||||
account_online_action = u"Action when state is 'Online'"
|
||||
account_away_action = u"Action when state is 'Away'"
|
||||
account_xa_action = u"Action when state is 'Not Available'"
|
||||
account_dnd_action = u"Action when state is 'Do not Disturb'"
|
||||
account_offline_action = u"Action when state is 'Offline'"
|
||||
account_check_interval = u"Mail check interval (in minutes)"
|
||||
action_nothing = u"Do nothing"
|
||||
action_retrieve = u"Retrieve mail"
|
||||
action_digest = u"Send mail digest"
|
||||
update_title = u"Jabber mail connection update"
|
||||
update_instructions = u"Modifying connection "
|
||||
connection = u" connection "
|
||||
update_account_message = u"Updated %s connection '%s': Registered with "\
|
||||
"username '%s' and password '%s' on '%s'"
|
||||
new_account_message = u"New %s connection '%s': Registered with " \
|
||||
"username '%s' and password '%s' on '%s'"
|
||||
|
||||
|
||||
3
jmc.py
3
jmc.py
@@ -31,6 +31,9 @@ from jabber.config import Config
|
||||
|
||||
def main(config_file = "jmc.xml", isDebug = 0):
|
||||
try:
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf-8')
|
||||
del sys.setdefaultencoding
|
||||
logger = logging.getLogger()
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
if isDebug > 0:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<secret>secret</secret>
|
||||
<service>jmc.localhost</service>
|
||||
<connectsleep>5</connectsleep>
|
||||
<language>fr</language>
|
||||
<language>en</language>
|
||||
<vCard>
|
||||
<FN>Jabber Mail Component</FN>
|
||||
<DESC>A Jabber mail server component</DESC>
|
||||
|
||||
Reference in New Issue
Block a user