# HG changeset patch # User souliane # Date 1409050366 -7200 # Node ID 75025461141f7f1721bde599e9c651d06054b5fa # Parent a7cdf03c00e984e68f97ce10ff5178237314637f move sat.tools.jid to sat_frontends.tools.jid diff -r a7cdf03c00e9 -r 75025461141f frontends/src/jp/base.py --- a/frontends/src/jp/base.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/jp/base.py Tue Aug 26 12:52:46 2014 +0200 @@ -36,7 +36,7 @@ from gi.repository import GLib, GObject from glob import iglob from importlib import import_module -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID from sat_frontends.bridge.DBus import DBusBridgeFrontend from sat.core import exceptions import sat_frontends.jp diff -r a7cdf03c00e9 -r 75025461141f frontends/src/jp/cmd_profile.py --- a/frontends/src/jp/cmd_profile.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/jp/cmd_profile.py Tue Aug 26 12:52:46 2014 +0200 @@ -23,7 +23,7 @@ from logging import debug, info, error, warning from sat.core.i18n import _ from sat_frontends.jp import base -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID __commands__ = ["Profile"] diff -r a7cdf03c00e9 -r 75025461141f frontends/src/primitivus/chat.py --- a/frontends/src/primitivus/chat.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/primitivus/chat.py Tue Aug 26 12:52:46 2014 +0200 @@ -27,7 +27,7 @@ from sat_frontends.primitivus import xmlui from sat_frontends.primitivus.constants import Const as C import time -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID class ChatText(urwid.FlowWidget): diff -r a7cdf03c00e9 -r 75025461141f frontends/src/primitivus/contact_list.py --- a/frontends/src/primitivus/contact_list.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/primitivus/contact_list.py Tue Aug 26 12:52:46 2014 +0200 @@ -22,7 +22,7 @@ from urwid_satext import sat_widgets from sat_frontends.quick_frontend.quick_contact_list import QuickContactList from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID from sat_frontends.primitivus.status import StatusBar from sat_frontends.primitivus.constants import Const @@ -79,7 +79,7 @@ def setFocus(self, text, select=False): """give focus to the first element that matches the given text. You can also - pass in text a sat.tools.jid.JID (it's a subclass of unicode). + pass in text a sat_frontends.tools.jid.JID (it's a subclass of unicode). @param text: contact group name, contact or muc userhost, muc private dialog jid @param select: if True, the element is also clicked """ diff -r a7cdf03c00e9 -r 75025461141f frontends/src/primitivus/primitivus --- a/frontends/src/primitivus/primitivus Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/primitivus/primitivus Tue Aug 26 12:52:46 2014 +0200 @@ -38,7 +38,7 @@ from sat_frontends.primitivus.notify import Notify from sat_frontends.tools.misc import InputHistory from sat_frontends.constants import Const as commonConst # FIXME -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID from os.path import join diff -r a7cdf03c00e9 -r 75025461141f frontends/src/primitivus/profile_manager.py --- a/frontends/src/primitivus/profile_manager.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/primitivus/profile_manager.py Tue Aug 26 12:52:46 2014 +0200 @@ -21,7 +21,7 @@ from sat_frontends.primitivus.constants import Const as C import urwid from urwid_satext.sat_widgets import AdvancedEdit, Password, List, InputDialog, ConfirmDialog, Alert -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID class ProfileManager(urwid.WidgetWrap): diff -r a7cdf03c00e9 -r 75025461141f frontends/src/quick_frontend/constants.py --- a/frontends/src/quick_frontend/constants.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/quick_frontend/constants.py Tue Aug 26 12:52:46 2014 +0200 @@ -22,4 +22,4 @@ class Const(constants.Const): - PRIVATE_PREFIX = "@PRIVATE@" + PRIVATE_PREFIX = "@private@" diff -r a7cdf03c00e9 -r 75025461141f frontends/src/quick_frontend/quick_app.py --- a/frontends/src/quick_frontend/quick_app.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/quick_frontend/quick_app.py Tue Aug 26 12:52:46 2014 +0200 @@ -21,7 +21,7 @@ import sys from sat.core.log import getLogger log = getLogger(__name__) -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID from sat_frontends.bridge.DBus import DBusBridgeFrontend from sat.core import exceptions from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate diff -r a7cdf03c00e9 -r 75025461141f frontends/src/quick_frontend/quick_card_game.py --- a/frontends/src/quick_frontend/quick_card_game.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/quick_frontend/quick_card_game.py Tue Aug 26 12:52:46 2014 +0200 @@ -19,7 +19,7 @@ from sat.core.log import getLogger log = getLogger(__name__) -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID diff -r a7cdf03c00e9 -r 75025461141f frontends/src/quick_frontend/quick_chat.py --- a/frontends/src/quick_frontend/quick_chat.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/quick_frontend/quick_chat.py Tue Aug 26 12:52:46 2014 +0200 @@ -20,7 +20,7 @@ from sat.core.i18n import _ from sat.core.log import getLogger log = getLogger(__name__) -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID from sat_frontends.quick_frontend.quick_utils import unescapePrivate from sat_frontends.quick_frontend.constants import Const diff -r a7cdf03c00e9 -r 75025461141f frontends/src/quick_frontend/quick_chat_list.py --- a/frontends/src/quick_frontend/quick_chat_list.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/quick_frontend/quick_chat_list.py Tue Aug 26 12:52:46 2014 +0200 @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID class QuickChatList(dict): diff -r a7cdf03c00e9 -r 75025461141f frontends/src/quick_frontend/quick_contact_management.py --- a/frontends/src/quick_frontend/quick_contact_management.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/quick_frontend/quick_contact_management.py Tue Aug 26 12:52:46 2014 +0200 @@ -20,7 +20,7 @@ from sat.core.i18n import _ from sat.core.log import getLogger log = getLogger(__name__) -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID class QuickContactManagement(object): diff -r a7cdf03c00e9 -r 75025461141f frontends/src/quick_frontend/quick_utils.py --- a/frontends/src/quick_frontend/quick_utils.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/quick_frontend/quick_utils.py Tue Aug 26 12:52:46 2014 +0200 @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID from os.path import exists, splitext from sat_frontends.quick_frontend.constants import Const diff -r a7cdf03c00e9 -r 75025461141f frontends/src/tools/jid.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/frontends/src/tools/jid.py Tue Aug 26 12:52:46 2014 +0200 @@ -0,0 +1,48 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# SAT: a jabber client +# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 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 Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +class JID(unicode): + """This class help manage JID (Node@Domaine/Resource)""" + + def __new__(cls, jid): + self = unicode.__new__(cls, jid) + self.__parse() + return self + + def __parse(self): + """find node domain and resource""" + node_end = self.find('@') + if node_end < 0: + node_end = 0 + domain_end = self.find('/') + if domain_end < 1: + domain_end = len(self) + self.node = self[:node_end] + self.domain = self[(node_end + 1) if node_end else 0:domain_end] + self.resource = self[domain_end + 1:] + if not node_end: + self.bare = self + else: + self.bare = self.node + '@' + self.domain + + def is_valid(self): + """return True if the jid is xmpp compliant""" + #TODO: implement real check, according to RFCs + return self.domain != "" diff -r a7cdf03c00e9 -r 75025461141f frontends/src/wix/chat.py --- a/frontends/src/wix/chat.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/wix/chat.py Tue Aug 26 12:52:46 2014 +0200 @@ -25,7 +25,7 @@ import time from sat.core.log import getLogger log = getLogger(__name__) -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID from sat_frontends.quick_frontend.quick_chat import QuickChat from sat_frontends.wix.contact_list import ContactList from sat_frontends.wix.card_game import CardPanel diff -r a7cdf03c00e9 -r 75025461141f frontends/src/wix/contact_list.py --- a/frontends/src/wix/contact_list.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/wix/contact_list.py Tue Aug 26 12:52:46 2014 +0200 @@ -24,7 +24,7 @@ from sat.core.log import getLogger log = getLogger(__name__) from cgi import escape -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID from os.path import join diff -r a7cdf03c00e9 -r 75025461141f frontends/src/wix/main_window.py --- a/frontends/src/wix/main_window.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/wix/main_window.py Tue Aug 26 12:52:46 2014 +0200 @@ -29,7 +29,7 @@ from sat_frontends.wix.profile import Profile from sat_frontends.wix.profile_manager import ProfileManager import os.path -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID from sat.core.log import getLogger log = getLogger(__name__) from sat_frontends.wix.constants import Const diff -r a7cdf03c00e9 -r 75025461141f frontends/src/wix/profile.py --- a/frontends/src/wix/profile.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/wix/profile.py Tue Aug 26 12:52:46 2014 +0200 @@ -22,7 +22,7 @@ import pdb from sat.core.log import getLogger log = getLogger(__name__) -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID class Profile(wx.Frame): diff -r a7cdf03c00e9 -r 75025461141f frontends/src/wix/quiz_game.py --- a/frontends/src/wix/quiz_game.py Tue Aug 26 09:54:23 2014 +0200 +++ b/frontends/src/wix/quiz_game.py Tue Aug 26 12:52:46 2014 +0200 @@ -25,7 +25,7 @@ import pdb from sat.core.log import getLogger log = getLogger(__name__) -from sat.tools.jid import JID +from sat_frontends.tools.jid import JID from time import time from math import sin, cos, pi diff -r a7cdf03c00e9 -r 75025461141f src/tools/jid.py --- a/src/tools/jid.py Tue Aug 26 09:54:23 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# SAT: a jabber client -# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 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 Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - - -class JID(unicode): - """This class help manage JID (Node@Domaine/Resource)""" - - def __new__(cls, jid): - self = unicode.__new__(cls, jid) - self.__parse() - return self - - def __parse(self): - """find node domain and resource""" - node_end = self.find('@') - if node_end < 0: - node_end = 0 - domain_end = self.find('/') - if domain_end < 1: - domain_end = len(self) - self.node = self[:node_end] - self.domain = self[(node_end + 1) if node_end else 0:domain_end] - self.resource = self[domain_end + 1:] - if not node_end: - self.bare = self - else: - self.bare = self.node + '@' + self.domain - - def is_valid(self): - """return True if the jid is xmpp compliant""" - #TODO: implement real check, according to RFCs - return self.domain != ""