summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/default_config.cfg1
-rw-r--r--src/common.py15
-rw-r--r--src/connection.py13
3 files changed, 13 insertions, 16 deletions
diff --git a/data/default_config.cfg b/data/default_config.cfg
index 7f5d6e4c..881cc812 100644
--- a/data/default_config.cfg
+++ b/data/default_config.cfg
@@ -133,6 +133,7 @@ send_poezio_info = true
# if true, information about the Operation System you're using
# will be sent when requested by anyone
# Set to false if you don't want people to know these information
+# Note that this information will not be sent if send_poezio_info is False
send_os_info = true
# if true, your current time will be sent if asked
diff --git a/src/common.py b/src/common.py
index f19b872f..b909977c 100644
--- a/src/common.py
+++ b/src/common.py
@@ -122,19 +122,6 @@ DISTRO_INFO = {
'Redhat Linux': '/etc/redhat-release'
}
-def temp_failure_retry(func, *args, **kwargs):
- """
- workaround for a temporary and specific failure
- """
- while True:
- try:
- return func(*args, **kwargs)
- except (os.error, IOError, select.error) as ex:
- if ex.errno == errno.EINTR:
- continue
- else:
- raise
-
def get_os_info():
"""
Returns a detailed and well formated string containing
@@ -151,7 +138,7 @@ def get_os_info():
stdout=subprocess.PIPE,
close_fds=True)
process.wait()
- output = temp_failure_retry(process.stdout.readline).strip()
+ output = process.stdout.readline().decode('utf-8').strip()
# some distros put n/a in places, so remove those
output = output.replace('n/a', '').replace('N/A', '')
return output
diff --git a/src/connection.py b/src/connection.py
index 66ae9e55..0373c4e7 100644
--- a/src/connection.py
+++ b/src/connection.py
@@ -29,6 +29,7 @@ import sleekxmpp
from config import config
from logger import logger
+import common
class Connection(sleekxmpp.ClientXMPP):
"""
@@ -48,8 +49,16 @@ class Connection(sleekxmpp.ClientXMPP):
jid = '%s/%s' % (config.get('server', 'anon.louiz.org'), resource)
password = None
sleekxmpp.ClientXMPP.__init__(self, jid, password, ssl=True)
- self.registerPlugin('xep_0030')
- self.registerPlugin('xep_0045')
+ self.register_plugin('xep_0030')
+ self.register_plugin('xep_0045')
+ if config.get('send_poezio_info', 'true') == 'true':
+ info = {'name':'poezio',
+ 'version':'0.7-dev'}
+ if config.get('send_os_info', 'true') == 'true':
+ info['os'] = common.get_os_info()
+ self.register_plugin('xep_0092', pconfig=info)
+ if config.get('send_time', 'true') == 'true':
+ self.register_plugin('xep_0202')
def start(self):
# TODO, try multiple servers