Philipp Hörist pushed to branch master at gajim / gajim
Commits:
893e9810 by Philipp Hörist at 2019-08-17T22:17:12Z
Bookmarks: Store name/nickname/password on change
- - - - -
12411298 by Philipp Hörist at 2019-08-18T13:43:27Z
Fix test
There are no legacy accounts anymore
- - - - -
10ce4f5a by Philipp Hörist at 2019-08-18T20:34:03Z
MUC: Correctly handle forced nickname changes
- - - - -
3457e3f5 by Philipp Hörist at 2019-08-18T20:34:35Z
Groupchat: Fix detecting if subject change is allowed
- - - - -
4 changed files:
- gajim/common/modules/bookmarks.py
- gajim/common/modules/muc.py
- gajim/groupchat_control.py
- test/no_gui/unit/test_contacts.py
Changes:
=====================================
gajim/common/modules/bookmarks.py
=====================================
@@ -192,17 +192,16 @@ class Bookmarks(BaseModule):
nick: str) -> None:
bookmark = self.get_bookmark_from_jid(jid)
- if bookmark is None:
- bookmark = BookmarkData(jid=jid,
- name=name,
- autojoin=autojoin,
- password=password,
- nick=nick)
- self._bookmarks.append(bookmark)
- self.store_bookmarks()
-
- elif not bookmark.autojoin:
- self.set_autojoin(jid, True)
+ if bookmark is not None:
+ self._bookmarks.remove(bookmark)
+
+ bookmark = BookmarkData(jid=jid,
+ name=name,
+ autojoin=autojoin,
+ password=password,
+ nick=nick)
+ self._bookmarks.append(bookmark)
+ self.store_bookmarks()
def set_autojoin(self, jid, enabled):
bookmark = self.get_bookmark_from_jid(jid)
@@ -214,6 +213,26 @@ class Bookmarks(BaseModule):
self._bookmarks.append(bookmark)
self.store_bookmarks()
+ def set_nickname(self, jid, nick):
+ bookmark = self.get_bookmark_from_jid(jid)
+ if bookmark is None:
+ return
+ self._log.info('Set nick for: %s to %s', jid, nick)
+ self._bookmarks.remove(bookmark)
+ bookmark = bookmark._replace(nick=nick)
+ self._bookmarks.append(bookmark)
+ self.store_bookmarks()
+
+ def set_name(self, jid, name):
+ bookmark = self.get_bookmark_from_jid(jid)
+ if bookmark is None:
+ return
+ self._log.info('Set name for: %s to %s', jid, name)
+ self._bookmarks.remove(bookmark)
+ bookmark = bookmark._replace(name=name)
+ self._bookmarks.append(bookmark)
+ self.store_bookmarks()
+
def remove(self, jid: str, publish: bool = True) -> None:
bookmark = self.get_bookmark_from_jid(jid)
if bookmark is None:
=====================================
gajim/common/modules/muc.py
=====================================
@@ -389,10 +389,14 @@ class MUC(BaseModule):
if properties.is_nickname_changed:
if properties.is_muc_self_presence:
muc_data.nick = properties.muc_user.nick
+ self._con.get_module('Bookmarks').set_nickname(muc_data.jid,
+ muc_data.nick)
app.contacts.remove_gc_contact(self._account, contact)
contact.name = properties.muc_user.nick
app.contacts.add_gc_contact(self._account, contact)
- self._log.info('Nickname changed: %s to %s',
+ initiator = 'Server' if properties.is_nickname_modified else 'User'
+ self._log.info('%s nickname changed: %s to %s',
+ initiator,
properties.jid,
properties.muc_user.nick)
self._raise_muc_event('muc-nickname-changed', properties)
@@ -402,9 +406,14 @@ class MUC(BaseModule):
self._add_new_muc_contact(properties)
if properties.is_muc_self_presence:
self._log.info('Self presence: %s', properties.jid)
- self._raise_muc_event('muc-self-presence', properties)
if muc_data.state == MUCJoinedState.JOINING:
self._start_join_timeout(room_jid)
+ if (properties.is_nickname_modified or
+ muc_data.nick != properties.muc_nickname):
+ muc_data.nick = properties.muc_nickname
+ self._log.info('Server modified nickname to: %s',
+ properties.muc_nickname)
+ self._raise_muc_event('muc-self-presence', properties)
if properties.is_new_room:
self.configure_room(room_jid)
else:
=====================================
gajim/groupchat_control.py
=====================================
@@ -552,7 +552,7 @@ class GroupchatControl(ChatControlBase):
if self.disco_info is None:
return False
- return self.disco_info.muc_subjectmod
+ return self.disco_info.muc_subjectmod or False
def _get_action(self, name):
win = self.parent_win.window
=====================================
test/no_gui/unit/test_contacts.py
=====================================
@@ -95,14 +95,6 @@ class TestContacts(unittest.TestCase):
# Not yet implemented to remain backwart compatible
# self.assertEqual(contact, copy, msg="Must be equal")
- def test_legacy_accounts_handling(self):
- self.contacts.add_account("one")
- self.contacts.add_account("two")
-
- self.contacts.remove_account("one")
-
- self.assertEqual(["old"], self.contacts.get_accounts())
-
def test_legacy_contacts_from_groups(self):
jid1 = "[email protected]"
jid2 = "[email protected]"
View it on GitLab:
https://dev.gajim.org/gajim/gajim/compare/d800ca8e4272c830f24ed0a433be0a3f818276a2...3457e3f51c5c1a6de640553085dd5bfb66815cac
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/compare/d800ca8e4272c830f24ed0a433be0a3f818276a2...3457e3f51c5c1a6de640553085dd5bfb66815cac
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits