[Git][gajim/gajim][master] 2 commits: Remove unused code

Philipp Hörist gitlab at dev.gajim.org
Thu Jan 3 00:56:41 CET 2019


Philipp Hörist pushed to branch master at gajim / gajim


Commits:
d622439a by Philipp Hörist at 2019-01-02T23:50:00Z
Remove unused code

- - - - -
d1ccfd51 by Philipp Hörist at 2019-01-02T23:50:22Z
MUC: Dont check for unique room id support

This feature was remove from XEP-0045 in Version 1.25 (2012-02-08). We simply now use an uuid instead.

- - - - -


6 changed files:

- gajim/common/connection.py
- gajim/common/connection_handlers.py
- gajim/common/connection_handlers_events.py
- gajim/common/zeroconf/connection_handlers_zeroconf.py
- gajim/dialogs.py
- gajim/gui_interface.py


Changes:

=====================================
gajim/common/connection.py
=====================================
@@ -1653,22 +1653,6 @@ class Connection(CommonConnection, ConnectionHandlers):
             show=show,
             caps=ptype != 'unavailable')
 
-    def check_unique_room_id_support(self, server, instance):
-        if not app.account_is_connected(self.name):
-            return
-        iq = nbxmpp.Iq(typ='get', to=server)
-        iq.setAttr('id', 'unique1')
-        iq.addChild('unique', namespace=nbxmpp.NS_MUC_UNIQUE)
-        def _on_response(resp):
-            if not nbxmpp.isResultNode(resp):
-                app.nec.push_incoming_event(UniqueRoomIdNotSupportedEvent(
-                    None, conn=self, instance=instance, server=server))
-                return
-            app.nec.push_incoming_event(UniqueRoomIdSupportedEvent(None,
-                conn=self, instance=instance, server=server,
-                room_id=resp.getTag('unique').getData()))
-        self.connection.SendAndCallForResponse(iq, _on_response)
-
     def join_gc(self, nick, room_jid, password, change_nick=False,
     rejoin=False):
         # FIXME: This room JID needs to be normalized; see #1364


=====================================
gajim/common/connection_handlers.py
=====================================
@@ -260,11 +260,6 @@ class ConnectionHandlers(ConnectionSocks5Bytestream,
         ConnectionJingle.__init__(self)
         ConnectionHandlersBase.__init__(self)
 
-        # IDs of disco#items requests
-        self.disco_items_ids = []
-        # IDs of disco#info requests
-        self.disco_info_ids = []
-
         self.continue_connect_info = None
 
         # If handlers have been registered


=====================================
gajim/common/connection_handlers_events.py
=====================================
@@ -37,88 +37,6 @@ from gajim.common.file_props import FilesProp
 log = logging.getLogger('gajim.c.connection_handlers_events')
 
 
-class HelperEvent:
-    def get_jid_resource(self, check_fake_jid=False):
-        if check_fake_jid and hasattr(self, 'id_') and \
-                self.id_ in self.conn.groupchat_jids:
-            self.fjid = self.conn.groupchat_jids[self.id_]
-            del self.conn.groupchat_jids[self.id_]
-        else:
-            self.fjid = helpers.get_full_jid_from_iq(self.stanza)
-        if self.fjid is None:
-            self.jid = None
-        else:
-            self.jid, self.resource = app.get_room_and_nick_from_fjid(self.fjid)
-
-    def get_id(self):
-        self.id_ = self.stanza.getID()
-
-    def get_gc_control(self):
-        self.gc_control = app.interface.msg_win_mgr.get_gc_control(self.jid,
-                                                                     self.conn.name)
-
-        # If gc_control is missing - it may be minimized. Try to get it
-        # from there. If it's not there - then it's missing anyway and
-        # will remain set to None.
-        if not self.gc_control:
-            minimized = app.interface.minimized_controls[self.conn.name]
-            self.gc_control = minimized.get(self.jid)
-
-    def get_oob_data(self, stanza):
-        oob_node = stanza.getTag('x', namespace=nbxmpp.NS_X_OOB)
-        if oob_node is not None:
-            oob_url = oob_node.getTagData('url')
-            if oob_url is not None:
-                self.additional_data.set_value('gajim', 'oob_url', oob_url)
-            oob_desc = oob_node.getTagData('desc')
-            if oob_desc is not None:
-                self.additional_data.set_value('gajim', 'oob_desc', oob_desc)
-
-    def get_stanza_id(self, stanza, query=False):
-        if query:
-            # On a MAM query the stanza-id is maybe not set, so
-            # get the id of the stanza
-            return stanza.getAttr('id')
-        stanza_id, by = stanza.getStanzaIDAttrs()
-        if by is None:
-            # We can not verify who set this stanza-id, ignore it.
-            return
-        if stanza.getType() == 'groupchat':
-            if stanza.getFrom().bareMatch(by):
-                # by attribute must match the server
-                return stanza_id
-        elif self.conn.get_own_jid().bareMatch(by):
-            # by attribute must match the server
-            return stanza_id
-        return
-
-    @staticmethod
-    def get_forwarded_message(stanza):
-        forwarded = stanza.getTag('forwarded',
-                                  namespace=nbxmpp.NS_FORWARD,
-                                  protocol=True)
-        if forwarded is not None:
-            return forwarded.getTag('message', protocol=True)
-
-    def _is_self_message(self, message):
-        if self.self_message is not None:
-            return self.self_message
-        own_jid = self.conn.get_own_jid()
-        frm = message.getFrom()
-        to = message.getTo()
-        # If 'to' is not set we assume own jid
-        self.self_message = frm.bareMatch(to or own_jid)
-        return self.self_message
-
-    def _is_muc_pm(self, message):
-        if self.muc_pm is not None:
-            return self.muc_pm
-        self.muc_pm = False
-        muc_user = message.getTag('x', namespace=nbxmpp.NS_MUC_USER)
-        if muc_user is not None:
-            self.muc_pm = muc_user.getChildren() == []
-        return self.muc_pm
-
 class StreamReceivedEvent(nec.NetworkIncomingEvent):
     name = 'stream-received'
 
@@ -151,7 +69,7 @@ class MessageSentEvent(nec.NetworkIncomingEvent):
 class MessageNotSentEvent(nec.NetworkIncomingEvent):
     name = 'message-not-sent'
 
-class MessageErrorEvent(nec.NetworkIncomingEvent, HelperEvent):
+class MessageErrorEvent(nec.NetworkIncomingEvent):
     name = 'message-error'
 
     def init(self):
@@ -160,7 +78,7 @@ class MessageErrorEvent(nec.NetworkIncomingEvent, HelperEvent):
     def generate(self):
         if self.zeroconf:
             return True
-        self.get_id()
+        self.id_ = self.stanza.getID()
         #only alert for errors of explicitly sent messages (see https://trac.gajim.org/ticket/8222)
         if self.id_ in self.conn.sent_message_ids:
             self.conn.sent_message_ids.remove(self.id_)
@@ -292,15 +210,6 @@ class InsecureSSLConnectionEvent(nec.NetworkIncomingEvent):
 class SSLErrorEvent(nec.NetworkIncomingEvent):
     name = 'ssl-error'
 
-class UniqueRoomIdSupportedEvent(nec.NetworkIncomingEvent):
-    name = 'unique-room-id-supported'
-
-class UniqueRoomIdNotSupportedEvent(nec.NetworkIncomingEvent):
-    name = 'unique-room-id-not-supported'
-
-class NonAnonymousServerErrorEvent(nec.NetworkIncomingEvent):
-    name = 'non-anonymous-server-error'
-
 class UpdateGCAvatarEvent(nec.NetworkIncomingEvent):
     name = 'update-gc-avatar'
 
@@ -328,7 +237,7 @@ class PasswordRequiredEvent(nec.NetworkIncomingEvent):
 class SignedInEvent(nec.NetworkIncomingEvent):
     name = 'signed-in'
 
-class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
+class FileRequestReceivedEvent(nec.NetworkIncomingEvent):
     name = 'file-request-received'
 
     def init(self):
@@ -336,7 +245,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
         self.FT_content = None
 
     def generate(self):
-        self.get_id()
+        self.id_ = self.stanza.getID()
         self.fjid = self.conn._ft_get_from(self.stanza)
         self.jid = app.get_jid_without_resource(self.fjid)
         if self.jingle_content:


=====================================
gajim/common/zeroconf/connection_handlers_zeroconf.py
=====================================
@@ -54,20 +54,11 @@ class DecryptedMessageReceivedEvent(NetworkIncomingEvent):
     name = 'decrypted-message-received'
 
 
-class ConnectionVcard:
-    def add_sha(self, p, *args):
-        return p
 
-    def add_caps(self, p):
-        return p
-
-
-class ConnectionHandlersZeroconf(ConnectionVcard,
-ConnectionSocks5BytestreamZeroconf,
-connection_handlers.ConnectionHandlersBase,
-connection_handlers.ConnectionJingle):
+class ConnectionHandlersZeroconf(ConnectionSocks5BytestreamZeroconf,
+                                 connection_handlers.ConnectionHandlersBase,
+                                 connection_handlers.ConnectionJingle):
     def __init__(self):
-        ConnectionVcard.__init__(self)
         ConnectionSocks5BytestreamZeroconf.__init__(self)
         connection_handlers.ConnectionJingle.__init__(self)
         connection_handlers.ConnectionHandlersBase.__init__(self)


=====================================
gajim/dialogs.py
=====================================
@@ -30,8 +30,8 @@ from typing import List  # pylint: disable=unused-import
 from typing import Tuple  # pylint: disable=unused-import
 
 import os
+import uuid
 import logging
-from random import randrange
 
 from gi.repository import Gtk
 from gi.repository import Gdk
@@ -1459,21 +1459,12 @@ class TransformChatToMUC:
                         path = self.guests_store.get_path(iter_)
                         self.guests_treeview.get_selection().select_path(path)
 
-        app.ged.register_event_handler('unique-room-id-supported', ged.GUI1,
-            self._nec_unique_room_id_supported)
-        app.ged.register_event_handler('unique-room-id-not-supported',
-            ged.GUI1, self._nec_unique_room_id_not_supported)
-
         # show all
         self.window.show_all()
 
         self.xml.connect_signals(self)
 
     def on_chat_to_muc_window_destroy(self, widget):
-        app.ged.remove_event_handler('unique-room-id-supported', ged.GUI1,
-            self._nec_unique_room_id_supported)
-        app.ged.remove_event_handler('unique-room-id-not-supported', ged.GUI1,
-            self._nec_unique_room_id_not_supported)
         self.instances.remove(self)
 
     def on_chat_to_muc_window_key_press_event(self, widget, event):
@@ -1486,11 +1477,7 @@ class TransformChatToMUC:
         server = model[row][0].strip()
         if server == '':
             return
-        app.connections[self.account].check_unique_room_id_support(server, self)
 
-    def _nec_unique_room_id_supported(self, obj):
-        if obj.instance != self:
-            return
         guest_list = []
         guests = self.guests_treeview.get_selection().get_selected_rows()
         for guest in guests[1]:
@@ -1498,7 +1485,7 @@ class TransformChatToMUC:
             guest_list.append(self.guests_store[iter_][2])
         for guest in self.auto_jids:
             guest_list.append(guest)
-        room_jid = obj.room_id + '@' + obj.server
+        room_jid = str(uuid.uuid4()) + '@' + server
         app.automatic_rooms[self.account][room_jid] = {}
         app.automatic_rooms[self.account][room_jid]['invities'] = guest_list
         app.automatic_rooms[self.account][room_jid]['continue_tag'] = True
@@ -1509,13 +1496,6 @@ class TransformChatToMUC:
     def on_cancel_button_clicked(self, widget):
         self.window.destroy()
 
-    def _nec_unique_room_id_not_supported(self, obj):
-        if obj.instance != self:
-            return
-        obj.room_id = app.nicks[self.account].lower().replace(' ', '') + \
-            str(randrange(9999999))
-        self._nec_unique_room_id_supported(obj)
-
 class Dialog(Gtk.Dialog):
     def __init__(self, parent, title, buttons, default=None,
     on_response_ok=None, on_response_cancel=None):


=====================================
gajim/gui_interface.py
=====================================
@@ -1273,13 +1273,6 @@ class Interface:
         self.instances[account]['online_dialog']['ssl_error'].set_title(
             _('SSL Certificate Verification for %s') % account)
 
-    def handle_event_non_anonymous_server(self, obj):
-        account = obj.conn.name
-        server = app.config.get_per('accounts', account, 'hostname')
-        ErrorDialog(_('Non Anonymous Server'), sectext='Server "%s"'
-            'does not support anonymous connection' % server,
-            transient_for=self.roster.window)
-
     def handle_event_plain_connection(self, obj):
         # ('PLAIN_CONNECTION', account, (connection))
         def on_ok(is_checked):
@@ -1392,7 +1385,6 @@ class Interface:
                 [self.handle_event_roster_item_exchange],
             'signed-in': [self.handle_event_signed_in],
             'ssl-error': [self.handle_event_ssl_error],
-            'non-anonymous-server-error': [self.handle_event_non_anonymous_server],
             'stream-conflict-received': [self.handle_event_resource_conflict],
             'subscribe-presence-received': [
                 self.handle_event_subscribe_presence],



View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/9ae6654dd37189392258eb0d32690c2b257917c6...d1ccfd515a74debe8f6a526844577b4f02733841

-- 
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/9ae6654dd37189392258eb0d32690c2b257917c6...d1ccfd515a74debe8f6a526844577b4f02733841
You're receiving this email because of your account on dev.gajim.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gajim.org/pipermail/commits/attachments/20190103/bff97c70/attachment-0001.html>


More information about the Commits mailing list