Commit 7e3d3f95 authored by Philipp Hörist's avatar Philipp Hörist

Use json format for the servers list

parent 12cd2852
......@@ -39,6 +39,7 @@ import shlex
import socket
import time
import logging
import json
from datetime import datetime, timedelta
from distutils.version import LooseVersion as V
from encodings.punycode import punycode_encode
......@@ -1492,3 +1493,15 @@ def get_sync_threshold(jid, archive_info):
app.logger.set_archive_infos(jid, sync_threshold=threshold)
return threshold
return archive_info.sync_threshold
def load_json(path, key=None, default=None):
try:
with open(path, 'r') as file:
json_dict = json.loads(file.read())
except Exception:
log.exception('Parsing error')
return default
if key is None:
return json_dict
return json_dict.get(key, default)
{
"servers":[
"0nl1ne.at",
"404.city",
"brauchen.info",
"chatme.im",
"climm.org",
"comm.unicate.me",
"creep.im",
"deshalbfrei.org",
"draugr.de",
"einfachjabber.de",
"forumanalogue.fr",
"im.apinc.org",
"im.flosoft.biz",
"jabber-hosting.de",
"jabber.at",
"jabber.ccc.de",
"jabber.chaotic.de",
"jabber.co.nz",
"jabber.cz",
"jabber.earth.li",
"jabber.fourecks.de",
"jabber.hot-chilli.net",
"jabber.i-pobox.net",
"jabber.me",
"jabber.meta.net.nz",
"jabber.no",
"jabber.sk",
"jabber.org",
"jabber.rueckgr.at",
"jabber.scha.de",
"jabber.second-home.de",
"jabber.smash-net.org",
"jabber.sow.as",
"jabber.theforest.us",
"jabberafrica.org",
"jabberes.org",
"jabberpl.org",
"jabbim.com",
"jabbim.cz",
"jabbim.hu",
"jabbim.pl",
"jabbim.sk",
"jabster.pl",
"jaim.at",
"lightwitch.org",
"linuxlovers.at",
"lsd-25.ru",
"njs.netlab.cz",
"palita.net",
"pandion.im",
"richim.org",
"sss.chaoslab.ru",
"sternenschweif.de",
"suchat.org",
"swissjabber.ch",
"swissjabber.de",
"swissjabber.eu",
"swissjabber.li",
"swissjabber.org",
"tcweb.org",
"tekst.me",
"tigase.im",
"ubuntu-jabber.de",
"ubuntu-jabber.net",
"univers-libre.net",
"uprod.biz",
"verdammung.org",
"wtfismyip.com",
"xabber.de",
"xmpp-hosting.de",
"xmpp.jp",
"xmppnet.de",
"zsim.de"
]
}
<?xml version="1.0" encoding="utf-8"?>
<!--
This file lists the open XMPP servers registered with the XSF.
The format of this file is defined by the Service Discovery
protocol: http://xmpp.org/extensions/xep-0030.html
To add your server to the list, follow the instructions at
http://xmpp.org/services/register.shtml
-->
<query xmlns:reg="urn:xmpp:vcard:registration:1">
<item jid="0nl1ne.at" />
<item jid="404.city" />
<item jid="brauchen.info" />
<item jid="chatme.im" />
<item jid="climm.org" />
<item jid="comm.unicate.me" />
<item jid="creep.im" />
<item jid="deshalbfrei.org" />
<item jid="draugr.de" />
<item jid="einfachjabber.de" />
<item jid="forumanalogue.fr" />
<item jid="im.apinc.org" />
<item jid="im.flosoft.biz" />
<item jid="jabber-hosting.de" />
<item jid="jabber.at" />
<item jid="jabber.ccc.de" />
<item jid="jabber.chaotic.de" />
<item jid="jabber.co.nz" />
<item jid="jabber.cz" />
<item jid="jabber.earth.li" />
<item jid="jabber.fourecks.de" />
<item jid="jabber.hot-chilli.net" />
<item jid="jabber.i-pobox.net" />
<item jid="jabber.me" />
<item jid="jabber.meta.net.nz" />
<item jid="jabber.no" />
<item jid="jabber.sk" />
<item jid="jabber.org" />
<item jid="jabber.rueckgr.at" />
<item jid="jabber.scha.de" />
<item jid="jabber.second-home.de" />
<item jid="jabber.smash-net.org" />
<item jid="jabber.sow.as" />
<item jid="jabber.theforest.us" />
<item jid="jabberafrica.org" />
<item jid="jabberes.org" />
<item jid="jabberpl.org" />
<item jid="jabbim.com" />
<item jid="jabbim.cz" />
<item jid="jabbim.hu" />
<item jid="jabbim.pl" />
<item jid="jabbim.sk" />
<item jid="jabster.pl" />
<item jid="jaim.at" />
<item jid="lightwitch.org" />
<item jid="linuxlovers.at" />
<item jid="lsd-25.ru" />
<item jid="njs.netlab.cz" />
<item jid="palita.net" />
<item jid="pandion.im" />
<item jid="richim.org" />
<item jid="sss.chaoslab.ru" />
<item jid="sternenschweif.de" />
<item jid="suchat.org" />
<item jid="swissjabber.ch" />
<item jid="swissjabber.de" />
<item jid="swissjabber.eu" />
<item jid="swissjabber.li" />
<item jid="swissjabber.org" />
<item jid="tcweb.org" />
<item jid="tekst.me" />
<item jid="tigase.im" />
<item jid="ubuntu-jabber.de" />
<item jid="ubuntu-jabber.net" />
<item jid="univers-libre.net" />
<item jid="uprod.biz" />
<item jid="verdammung.org" />
<item jid="wtfismyip.com" />
<item jid="xabber.de" />
<item jid="xmpp-hosting.de" />
<item jid="xmpp.jp" />
<item jid="xmppnet.de" />
<item jid="zsim.de" />
</query>
......@@ -55,10 +55,11 @@ class AccountCreationWizard:
self.update_proxy_list()
# parse servers.xml
servers_xml = os.path.join(
configpaths.get('DATA'), 'other', 'servers.xml')
servers = gtkgui_helpers.parse_server_xml(servers_xml)
# parse servers.json
server_file_path = os.path.join(
configpaths.get('DATA'), 'other', 'servers.json')
servers = helpers.load_json(server_file_path, 'servers', [])
servers_model = self.xml.get_object('server_liststore')
for server in servers:
servers_model.append((server,))
......
......@@ -236,32 +236,6 @@ def scroll_to_end(widget):
adj_h.set_value(0)
return False
class ServersXMLHandler(ContentHandler):
def __init__(self):
ContentHandler.__init__(self)
self.servers = []
def startElement(self, name, attributes):
if name == 'item':
if 'jid' in attributes.getNames():
self.servers.append(attributes.getValue('jid'))
def endElement(self, name):
pass
def parse_server_xml(path_to_file):
try:
handler = ServersXMLHandler()
xml.sax.parse(path_to_file, handler)
return handler.servers
# handle exception if unable to open file
except IOError as message:
print(_('Error reading file:') + str(message), file=sys.stderr)
# handle exception parsing file
except xml.sax.SAXParseException as message:
print(_('Error parsing file:') + str(message), file=sys.stderr)
def set_unset_urgency_hint(window, unread_messages_no):
"""
Sets/unset urgency hint in window argument depending if we have unread
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment