Philipp Hörist pushed to branch master at gajim / gajim
Commits:
9dbac0f0 by Philipp Hörist at 2019-05-17T21:38:06Z
Remove custom status per contact feature
- - - - -
f601ca0d by Philipp Hörist at 2019-05-17T23:04:11Z
Add dedicated announce/motd module
- - - - -
11 changed files:
- gajim/app_actions.py
- gajim/common/connection.py
- gajim/common/modules/__init__.py
- + gajim/common/modules/announce.py
- gajim/common/modules/privacylists.py
- gajim/data/gui/contact_context_menu.ui
- gajim/gtk/single_message.py
- gajim/gui_interface.py
- gajim/gui_menu_builder.py
- gajim/roster_window.py
- test/lib/gajim_mocks.py
Changes:
=====================================
gajim/app_actions.py
=====================================
@@ -277,9 +277,7 @@ def on_update_motd(action, param):
def on_delete_motd(action, param):
account = param.get_string()
- server = app.config.get_per('accounts', account, 'hostname')
- server += '/announce/motd/delete'
- app.connections[account].send_motd(server)
+ app.connections[account].get_module('Announce').delete_motd()
# Help Actions
=====================================
gajim/common/connection.py
=====================================
@@ -1566,14 +1566,6 @@ class Connection(CommonConnection, ConnectionHandlers):
app.nec.push_incoming_event(OurShowEvent(None, conn=self,
show=show))
- def send_motd(self, jid, subject='', msg='', xhtml=None):
- if not app.account_is_connected(self.name):
- return
- msg_iq = nbxmpp.Message(to=jid, body=msg, subject=subject,
- xhtml=xhtml)
-
- self.connection.send(msg_iq)
-
def _nec_message_outgoing(self, obj):
if obj.account != self.name:
return
=====================================
gajim/common/modules/__init__.py
=====================================
@@ -73,6 +73,7 @@ MODULES = [
'user_tune',
'vcard_avatars',
'vcard_temp',
+ 'announce',
]
_imported_modules = [] # type: List[tuple]
=====================================
gajim/common/modules/announce.py
=====================================
@@ -0,0 +1,37 @@
+# This file is part of Gajim.
+#
+# Gajim is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation; version 3 only.
+#
+# Gajim 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
+
+# Server MOTD and Announce
+
+import nbxmpp
+
+from gajim.common.modules.base import BaseModule
+
+
+class Announce(BaseModule):
+ def __init__(self, con):
+ BaseModule.__init__(self, con)
+
+ def delete_motd(self):
+ server = self._con.get_own_jid().getDomain()
+ jid = '%s/announce/motd/delete' % server
+ self.set_announce(jid)
+
+ def set_announce(self, jid, subject=None, body=None):
+ message = nbxmpp.Message(to=jid, body=body, subject=subject)
+ self._nbxmpp().send(message)
+
+
+def get_instance(*args, **kwargs):
+ return Announce(*args, **kwargs), 'Announce'
=====================================
gajim/common/modules/privacylists.py
=====================================
@@ -242,23 +242,6 @@ class PrivacyLists(BaseModule):
def _build_invisible_rule(self):
node = nbxmpp.Node('list', {'name': 'invisible'})
iq = nbxmpp.Iq('set', nbxmpp.NS_PRIVACY, payload=[node])
- if (self._account in app.interface.status_sent_to_groups and
- app.interface.status_sent_to_groups[self._account]):
- for group in app.interface.status_sent_to_groups[self._account]:
- item = node.setTag('item', {'type': 'group',
- 'value': group,
- 'action': 'allow',
- 'order': '1'})
- item.setTag('presence-out')
-
- if (self._account in app.interface.status_sent_to_users and
- app.interface.status_sent_to_users[self._account]):
- for jid in app.interface.status_sent_to_users[self._account]:
- item = node.setTag('item', {'type': 'jid',
- 'value': jid,
- 'action': 'allow',
- 'order': '2'})
- item.setTag('presence-out')
item = node.setTag('item', {'action': 'deny', 'order': '3'})
item.setTag('presence-out')
=====================================
gajim/data/gui/contact_context_menu.ui
=====================================
@@ -51,21 +51,6 @@
<property name="can_focus">False</property>
</object>
</child>
- <child>
- <object class="GtkMenuItem" id="send_custom_status_menuitem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Send Cus_tom Status</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menu5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="GtkMenuItem" id="execute_command_menuitem">
<property name="visible">True</property>
=====================================
gajim/gtk/single_message.py
=====================================
@@ -308,8 +308,9 @@ class SingleMessageWindow(Gtk.ApplicationWindow):
return True
if '/announce/' in to_whom_jid:
- app.connections[self.account].send_motd(to_whom_jid, subject,
- message)
+ con = app.connections[self.account]
+ con.get_module('Announce').set_announce(
+ to_whom_jid, subject, message)
continue
recipient_list.append(to_whom_jid)
=====================================
gajim/gui_interface.py
=====================================
@@ -311,13 +311,6 @@ class Interface:
account = obj.conn.name
jid = obj.jid
- # unset custom status
- if (obj.old_show == 0 and obj.new_show > 1) or \
- (obj.old_show > 1 and obj.new_show == 0 and obj.conn.connected > 1):
- if account in self.status_sent_to_users and \
- jid in self.status_sent_to_users[account]:
- del self.status_sent_to_users[account][jid]
-
if app.jid_is_transport(jid):
# It must be an agent
@@ -2272,8 +2265,6 @@ class Interface:
# This is the manager and factory of message windows set by the module
self.msg_win_mgr = None
self.minimized_controls = {}
- self.status_sent_to_users = {}
- self.status_sent_to_groups = {}
self.pass_dialog = {}
self.db_error_dialog = None
=====================================
gajim/gui_menu_builder.py
=====================================
@@ -221,7 +221,6 @@ control=None, gc_contact=None, is_anonymous=True):
send_file_menuitem = xml.get_object('send_file_menuitem')
information_menuitem = xml.get_object('information_menuitem')
history_menuitem = xml.get_object('history_menuitem')
- send_custom_status_menuitem = xml.get_object('send_custom_status_menuitem')
send_single_message_menuitem = xml.get_object('send_single_message_menuitem')
invite_menuitem = xml.get_object('invite_menuitem')
block_menuitem = xml.get_object('block_menuitem')
@@ -327,7 +326,7 @@ control=None, gc_contact=None, is_anonymous=True):
# Zeroconf Account
if app.config.get_per('accounts', account, 'is_zeroconf'):
- for item in (send_custom_status_menuitem, send_single_message_menuitem,
+ for item in (send_single_message_menuitem,
invite_menuitem, block_menuitem, unblock_menuitem, ignore_menuitem,
unignore_menuitem, subscription_menuitem,
manage_contact_menuitem, convert_to_gc_menuitem):
@@ -348,22 +347,6 @@ control=None, gc_contact=None, is_anonymous=True):
# normal account
- # send custom status icon
- blocked = False
- if helpers.jid_is_blocked(account, jid):
- blocked = True
- else:
- for group in contact.get_shown_groups():
- if helpers.group_is_blocked(account, group):
- blocked = True
- break
- transport = app.get_transport_name_from_jid(jid, use_config_setting=False)
- if transport and transport != 'jabber':
- # Transport contact, send custom status unavailable
- send_custom_status_menuitem.set_sensitive(False)
- elif blocked:
- send_custom_status_menuitem.set_sensitive(False)
-
if gc_contact:
if not gc_contact.jid:
# it's a pm and we don't know real JID
@@ -387,16 +370,6 @@ control=None, gc_contact=None, is_anonymous=True):
if app.account_is_disconnected(account):
invite_menuitem.set_sensitive(False)
- # One or several resource, we do the same for send_custom_status
- status_menuitems = Gtk.Menu()
- send_custom_status_menuitem.set_submenu(status_menuitems)
- for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'):
- # icon MUST be different instance for every item
- status_menuitem = Gtk.MenuItem.new_with_label(helpers.get_uf_show(s))
- status_menuitem.connect('activate', roster.on_send_custom_status,
- [(contact, account)], s)
- status_menuitems.append(status_menuitem)
-
send_single_message_menuitem.connect('activate',
roster.on_send_single_message_menuitem_activate, account, contact)
@@ -447,7 +420,7 @@ control=None, gc_contact=None, is_anonymous=True):
if app.account_is_disconnected(account):
for widget in (send_single_message_menuitem, subscription_menuitem,
add_to_roster_menuitem, remove_from_roster_menuitem,
- execute_command_menuitem, send_custom_status_menuitem):
+ execute_command_menuitem):
widget.set_sensitive(False)
@@ -507,24 +480,6 @@ def get_transport_menu(contact, account):
if helpers.jid_is_blocked(account, jid):
blocked = True
- # Send Custom Status
- send_custom_status_menuitem = Gtk.MenuItem.new_with_mnemonic(
- _('Send Cus_tom Status'))
- if blocked:
- send_custom_status_menuitem.set_sensitive(False)
- else:
- status_menuitems = Gtk.Menu()
- send_custom_status_menuitem.set_submenu(status_menuitems)
- for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'):
- status_menuitem = Gtk.MenuItem.new_with_label(helpers.get_uf_show(
- s))
- status_menuitem.connect('activate', roster.on_send_custom_status,
- [(contact, account)], s)
- status_menuitems.append(status_menuitem)
- menu.append(send_custom_status_menuitem)
- if app.account_is_disconnected(account):
- send_custom_status_menuitem.set_sensitive(False)
-
item = Gtk.SeparatorMenuItem.new() # separator
menu.append(item)
=====================================
gajim/roster_window.py
=====================================
@@ -2113,10 +2113,6 @@ class RosterWindow:
app.SHOW_LIST.index('invisible')
app.connections[account].change_status(status, txt, auto)
- if account in app.interface.status_sent_to_users:
- app.interface.status_sent_to_users[account] = {}
- if account in app.interface.status_sent_to_groups:
- app.interface.status_sent_to_groups[account] = {}
for gc_control in app.interface.msg_win_mgr.get_controls(
message_control.TYPE_GC) + \
list(app.interface.minimized_controls[account].values()):
@@ -3362,67 +3358,6 @@ class RosterWindow:
'offline.') % jids
ConfirmationDialog(pritext, sectext, on_response_ok=on_ok2)
- def on_send_custom_status(self, widget, contact_list, show, group=None):
- """
- Send custom status
- """
- # contact_list has only one element except if group != None
- def on_response(message, pep_dict):
- if message is None: # None if user pressed Cancel
- return
- account_list = []
- for (contact, account) in contact_list:
- if account not in account_list:
- account_list.append(account)
- # 1. update status_sent_to_[groups|users] list
- if group:
- for account in account_list:
- if account not in app.interface.status_sent_to_groups:
- app.interface.status_sent_to_groups[account] = {}
- app.interface.status_sent_to_groups[account][group] = show
- else:
- for (contact, account) in contact_list:
- if account not in app.interface.status_sent_to_users:
- app.interface.status_sent_to_users[account] = {}
- app.interface.status_sent_to_users[account][contact.jid] \
- = show
-
- # 2. update privacy lists if main status is invisible
- for account in account_list:
- if app.SHOW_LIST[app.connections[account].connected] == \
- 'invisible':
- con = app.connections[account]
- con.get_module('PrivacyLists').set_invisible_rule()
-
- # 3. send directed presence
- for (contact, account) in contact_list:
- our_jid = app.get_jid_from_account(account)
- jid = contact.jid
- if jid == our_jid:
- jid += '/' + contact.resource
- self.send_status(account, show, message, to=jid)
-
- def send_it(is_checked=None):
- if is_checked is not None: # dialog has been shown
- if is_checked: # user does not want to be asked again
- app.config.set('confirm_custom_status', 'no')
- else:
- app.config.set('confirm_custom_status', 'yes')
- self.get_status_message(show, on_response, show_pep=False,
- always_ask=True)
-
- confirm_custom_status = app.config.get('confirm_custom_status')
- if confirm_custom_status == 'no':
- send_it()
- return
- pritext = _('You are about to send a custom status. Are you sure you '
- 'want to continue?')
- sectext = _('This contact will temporarily see you as %(status)s, '
- 'but only until you change your status. Then they will see '
- 'your global status.') % {'status': show}
- ConfirmationDialogCheck(pritext, sectext,
- _('_Do not ask me again'), on_response_ok=send_it)
-
def on_status_combobox_changed(self, widget):
"""
When we change our status via the combobox
@@ -5025,30 +4960,13 @@ class RosterWindow:
list_online, show_bookmarked=show_bookmarked)
menu.append(invite_menuitem)
- # Send Custom Status
- send_custom_status_menuitem = Gtk.MenuItem.new_with_mnemonic(
- _('Send Cus_tom Status'))
- if helpers.group_is_blocked(account, group):
- send_custom_status_menuitem.set_sensitive(False)
- status_menuitems = Gtk.Menu()
- send_custom_status_menuitem.set_submenu(status_menuitems)
- for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'):
- status_menuitem = Gtk.MenuItem.new_with_label(
- helpers.get_uf_show(s))
- status_menuitem.connect('activate', self.on_send_custom_status,
- list_, s, group)
- status_menuitems.append(status_menuitem)
- menu.append(send_custom_status_menuitem)
-
# there is no singlemessage and custom status for zeroconf
if app.config.get_per('accounts', account, 'is_zeroconf'):
- send_custom_status_menuitem.set_sensitive(False)
send_group_message_item.set_sensitive(False)
if app.connections[account].connected < 2:
send_group_message_item.set_sensitive(False)
invite_menuitem.set_sensitive(False)
- send_custom_status_menuitem.set_sensitive(False)
if not group in helpers.special_groups:
item = Gtk.SeparatorMenuItem.new() # separator
=====================================
test/lib/gajim_mocks.py
=====================================
@@ -104,7 +104,6 @@ class MockInterface(Mock):
self.instances = {}
self.minimized_controls = {}
- self.status_sent_to_users = Mock()
class MockLogger(Mock):
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/9f8492ae694f6d3dbb705f9b1d84f1ecc…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/9f8492ae694f6d3dbb705f9b1d84f1ecc…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
c823ef6c by Daniel Brötzmann at 2019-05-15T21:23:46Z
Unify display of URLs in status messages
Status messages in group chats and private chats are now displayed
in the same way as status messages in single chat windows. This
avoids trailing brackets to be appended to a possible hyperlink inside
the status message. Fixes #8470
- - - - -
2 changed files:
- gajim/groupchat_control.py
- gajim/privatechat_control.py
Changes:
=====================================
gajim/groupchat_control.py
=====================================
@@ -1854,7 +1854,7 @@ class GroupchatControl(ChatControlBase):
nick = event.properties.muc_nickname
status = event.properties.status
- status = '' if status is None else ' (%s)' % status
+ status = '' if status is None else ' - %s' % status
show = helpers.get_uf_show(event.properties.show.value)
status_default = app.config.get('print_status_muc_default')
=====================================
gajim/privatechat_control.py
=====================================
@@ -132,7 +132,7 @@ class PrivateChatControl(ChatControl):
nick = event.properties.muc_nickname
status = event.properties.status
- status = '' if status is None else ' (%s)' % status
+ status = '' if status is None else ' - %s' % status
show = helpers.get_uf_show(event.properties.show.value)
status_default = app.config.get('print_status_muc_default')
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/c823ef6cebf77dfa52fa3737e46dde7da4…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/c823ef6cebf77dfa52fa3737e46dde7da4…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
ac4bde04 by Philipp Hörist at 2019-05-15T18:12:41Z
MAM: Always reset state on reconnect
It was not reset if the previous MAM query was interrupted because of a disconnect
- - - - -
2 changed files:
- gajim/common/connection.py
- gajim/common/modules/mam.py
Changes:
=====================================
gajim/common/connection.py
=====================================
@@ -1346,6 +1346,7 @@ class Connection(CommonConnection, ConnectionHandlers):
self._discover_server()
self._set_send_timeouts()
self.get_module('Chatstate').enabled = True
+ self.get_module('MAM').reset_state()
def _set_send_timeouts(self):
if app.config.get_per('accounts', self.name, 'keep_alives_enabled'):
=====================================
gajim/common/modules/mam.py
=====================================
@@ -68,6 +68,10 @@ class MAM(BaseModule):
account=self._account,
feature=self.archiving_namespace))
+ def reset_state(self):
+ self._mam_query_ids.clear()
+ self._catch_up_finished.clear()
+
def _from_valid_archive(self, _stanza, properties):
if properties.type.is_groupchat:
expected_archive = properties.jid
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/ac4bde0447a5553d6a2515a8eac664806c…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/ac4bde0447a5553d6a2515a8eac664806c…
You're receiving this email because of your account on dev.gajim.org.