Philipp Hörist pushed to branch master at gajim / gajim
Commits:
29cf416d by Philipp Hörist at 2017-10-15T21:34:32+02:00
Send Presence probe on unblock
- - - - -
03e32668 by Philipp Hörist at 2017-10-15T21:34:42+02:00
MUC: Hide block menu if privacy list is absent
- - - - -
ed764789 by Philipp Hörist at 2017-10-15T21:34:42+02:00
Show blocked contacts as offline
- - - - -
3 changed files:
- gajim/common/connection.py
- gajim/common/connection_handlers.py
- gajim/groupchat_control.py
Changes:
=====================================
gajim/common/connection.py
=====================================
--- a/gajim/common/connection.py
+++ b/gajim/common/connection.py
@@ -1639,6 +1639,7 @@ class Connection(CommonConnection, ConnectionHandlers):
self.connection.send(iq)
return
for contact in contact_list:
+ contact.show = 'offline'
self.send_custom_status('offline', message, contact.jid)
max_order = self.get_max_blocked_list_order()
new_rule = {'order': str(max_order + 1),
@@ -1687,6 +1688,9 @@ class Connection(CommonConnection, ConnectionHandlers):
return
for contact in contact_list:
self.send_custom_status(show, self.status, contact.jid)
+ # Send a presence Probe to get the current Status
+ probe = nbxmpp.Presence(contact.jid, 'probe', frm=self.get_own_jid())
+ self.connection.send(probe)
def block_group(self, group, contact_list, message):
if not self.privacy_rules_supported:
=====================================
gajim/common/connection_handlers.py
=====================================
--- a/gajim/common/connection_handlers.py
+++ b/gajim/common/connection_handlers.py
@@ -2104,9 +2104,15 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream):
for jid in obj.blocked_jids:
if jid not in self.blocked_contacts:
self.blocked_contacts.append(jid)
+ contact_list = app.contacts.get_contacts(self.name, jid)
+ for contact in contact_list:
+ contact.show = 'offline'
for jid in obj.unblocked_jids:
if jid in self.blocked_contacts:
self.blocked_contacts.remove(jid)
+ # Send a presence Probe to get the current Status
+ probe = nbxmpp.Presence(jid, 'probe', frm=self.get_own_jid())
+ self.connection.send(probe)
def _nec_stream_other_host_received(self, obj):
if obj.conn.name != self.name:
=====================================
gajim/groupchat_control.py
=====================================
--- a/gajim/groupchat_control.py
+++ b/gajim/groupchat_control.py
@@ -2613,7 +2613,12 @@ class GroupchatControl(ChatControlBase):
item = xml.get_object('block_menuitem')
item2 = xml.get_object('unblock_menuitem')
- if helpers.jid_is_blocked(self.account, fjid):
+ if not app.connections[self.account].privacy_rules_supported:
+ item2.set_no_show_all(True)
+ item.set_no_show_all(True)
+ item.hide()
+ item2.hide()
+ elif helpers.jid_is_blocked(self.account, fjid):
item.set_no_show_all(True)
item.hide()
id_ = item2.connect('activate', self.on_unblock, nick)
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/2446c7e3ed969e0426e4dae446fffd27a…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/2446c7e3ed969e0426e4dae446fffd27a…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
64d3bf63 by Philipp Hörist at 2017-10-15T00:52:34+02:00
Discover PEP on the account jid
see: https://xmpp.org/extensions/xep-0163.html#support
- - - - -
2e9de770 by Philipp Hörist at 2017-10-15T01:56:52+02:00
Remove discovery of generic pubsub support
We use PubSub only on our account jid, this use case is what PEP
was made for. If PEP is discovered we know that certain PubSub
features are supported, see: https://xmpp.org/extensions/xep-0163.html#defaults
The current check for <feature var='http://jabber.org/protocol/pubsub'/>
is pretty useless, as it just tells us that there is a PubSub implementation
but not much about the features. Only `publish` and `subscribe` are MUST
in XEP-0060 which is not enough for our needs.
If there is ever need to discover a generic PubSub implementation
that is not PEP we should check for all the PubSub features we need
instead of only for <feature var='http://jabber.org/protocol/pubsub'/>
- - - - -
3 changed files:
- gajim/common/connection.py
- gajim/groupchat_control.py
- gajim/server_info.py
Changes:
=====================================
gajim/common/connection.py
=====================================
--- a/gajim/common/connection.py
+++ b/gajim/common/connection.py
@@ -670,7 +670,6 @@ class Connection(CommonConnection, ConnectionHandlers):
self.music_track_info = 0
self.location_info = {}
- self.pubsub_supported = False
self.register_supported = False
self.pubsub_publish_options_supported = False
# Do we auto accept insecure connection
@@ -1914,28 +1913,25 @@ class Connection(CommonConnection, ConnectionHandlers):
self.archiving_supported = True
self.archiving_313_supported = True
get_action(self.name + '-archive').set_enabled(True)
+ for identity in obj.identities:
+ if identity['category'] == 'pubsub':
+ self.pep_supported = identity.get('type') == 'pep'
+ break
+ if nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS in obj.features:
+ self.pubsub_publish_options_supported = True
+ else:
+ # Remove stored bookmarks accessible to everyone.
+ self.send_pb_purge(our_jid, 'storage:bookmarks')
+ self.send_pb_delete(our_jid, 'storage:bookmarks')
if obj.fjid == hostname:
if nbxmpp.NS_SECLABEL in obj.features:
self.seclabel_supported = True
- for identity in obj.identities:
- if identity['category'] == 'pubsub' and identity.get(
- 'type') == 'pep':
- self.pep_supported = True
- break
if nbxmpp.NS_VCARD in obj.features:
self.vcard_supported = True
get_action(self.name + '-profile').set_enabled(True)
if nbxmpp.NS_REGISTER in obj.features:
self.register_supported = True
- if nbxmpp.NS_PUBSUB in obj.features:
- self.pubsub_supported = True
- if nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS in obj.features:
- self.pubsub_publish_options_supported = True
- else:
- # Remove stored bookmarks accessible to everyone.
- self.send_pb_purge(our_jid, 'storage:bookmarks')
- self.send_pb_delete(our_jid, 'storage:bookmarks')
if nbxmpp.NS_BLOCKING in obj.features:
self.blocking_supported = True
if nbxmpp.NS_ADDRESS in obj.features:
@@ -2364,8 +2360,7 @@ class Connection(CommonConnection, ConnectionHandlers):
return
if storage_type != 'xml':
- pubsub = self.pubsub_supported or self.pep_supported
- if pubsub and self.pubsub_publish_options_supported:
+ if self.pep_supported and self.pubsub_publish_options_supported:
self.send_pb_retrieve('', 'storage:bookmarks')
app.log('bookmarks').info('Request Bookmarks (PubSub)')
# some server (ejabberd) are so slow to answer that we
@@ -2423,8 +2418,7 @@ class Connection(CommonConnection, ConnectionHandlers):
storage_node = self.get_bookmarks_storage_node()
if storage_type != 'xml':
- pubsub = self.pubsub_supported or self.pep_supported
- if pubsub and self.pubsub_publish_options_supported:
+ if self.pep_supported and self.pubsub_publish_options_supported:
self.send_pb_publish(
'', 'storage:bookmarks', storage_node, 'current',
options=self.get_bookmark_publish_options())
=====================================
gajim/groupchat_control.py
=====================================
--- a/gajim/groupchat_control.py
+++ b/gajim/groupchat_control.py
@@ -354,7 +354,7 @@ class GroupchatControl(ChatControlBase):
img.set_from_icon_name('bookmark-new', Gtk.IconSize.MENU)
widget.set_sensitive(
app.connections[self.account].private_storage_supported or \
- (app.connections[self.account].pubsub_supported and \
+ (app.connections[self.account].pep_supported and \
app.connections[self.account].pubsub_publish_options_supported))
widget.show()
@@ -971,7 +971,7 @@ class GroupchatControl(ChatControlBase):
notify_menuitem.set_active(app.config.get_per('rooms', self.contact.jid,
'notify_on_all_messages'))
conn = app.connections[self.account]
- if not conn.private_storage_supported and (not conn.pubsub_supported or \
+ if not conn.private_storage_supported and (not conn.pep_supported or \
not conn.pubsub_publish_options_supported):
bookmark_room_menuitem.set_sensitive(False)
if app.gc_connected[self.account][self.room_jid]:
=====================================
gajim/server_info.py
=====================================
--- a/gajim/server_info.py
+++ b/gajim/server_info.py
@@ -118,9 +118,8 @@ class ServerInfoDialog(Gtk.Dialog):
Feature('XEP-0016: Privacy Lists', con.privacy_rules_supported, None),
Feature('XEP-0045: Multi-User Chat', con.muc_jid, None),
Feature('XEP-0054: vcard-temp', con.vcard_supported, None),
- Feature('XEP-0060: PubSub', con.pubsub_supported, None),
- Feature('XEP-0060: Publish Options', con.pubsub_publish_options_supported, None),
Feature('XEP-0163: Personal Eventing Protocol', con.pep_supported, None),
+ Feature('XEP-0163: #publish-options', con.pubsub_publish_options_supported, None),
Feature('XEP-0191: Blocking Command', con.blocking_supported, nbxmpp.NS_BLOCKING),
Feature('XEP-0198: Stream Management', con.sm.enabled, nbxmpp.NS_STREAM_MGMT),
Feature('XEP-0280: Message Carbons', con.carbons_enabled, nbxmpp.NS_CARBONS),
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/16ad6080663e575be1367bcc35d446d51…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/16ad6080663e575be1367bcc35d446d51…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
16ad6080 by Philipp Hörist at 2017-10-14T21:08:58+02:00
Minimize Roster correctly on ESC
Fixes #8765
- - - - -
1 changed file:
- gajim/roster_window.py
Changes:
=====================================
gajim/roster_window.py
=====================================
--- a/gajim/roster_window.py
+++ b/gajim/roster_window.py
@@ -3755,7 +3755,7 @@ class RosterWindow:
'quit_on_roster_x_button') and ((app.interface.systray_enabled and\
app.config.get('trayicon') == 'always') or app.config.get(
'allow_hide_roster')):
- self.window.hide()
+ self.window.iconify()
elif event.get_state() & Gdk.ModifierType.CONTROL_MASK and event.keyval == \
Gdk.KEY_i:
treeselection = self.tree.get_selection()
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/16ad6080663e575be1367bcc35d446d519…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/16ad6080663e575be1367bcc35d446d519…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
5aeed6c7 by Philipp Hörist at 2017-10-14T16:10:14+02:00
Remove AcronymExpanderPlugin
Moved to the gajim-plugins repository
- - - - -
4 changed files:
- − plugins/acronyms_expander/__init__.py
- − plugins/acronyms_expander/acronyms
- − plugins/acronyms_expander/acronyms_expander.py
- − plugins/acronyms_expander/manifest.ini
Changes:
=====================================
plugins/acronyms_expander/__init__.py deleted
=====================================
--- a/plugins/acronyms_expander/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from .acronyms_expander import AcronymsExpanderPlugin
=====================================
plugins/acronyms_expander/acronyms deleted
=====================================
--- a/plugins/acronyms_expander/acronyms
+++ /dev/null
@@ -1,69 +0,0 @@
-{"afaik": "as far as I know",
-"afaict": "as far as I can tell",
-"afk": "away from keyboard",
-"atm": "at the moment",
-"bbiab": "be back in a bit",
-"bbiaf": "be back in a few (minutes)",
-"bbl": "be back later",
-"bbs": "be back soon",
-"b/c": "because",
-"bf": "boyfriend",
-"bfo": "blinding flash of the obvious",
-"brb": "be right back",
-"bsod": "blue screen of death",
-"btw": "by the way",
-"ciao": "Italian for goodbye",
-"ctrn": "can't talk right now",
-"cul8r": "see you later",
-"cya": "see ya",
-"dhtb": "don't have the bandwidth",
-"f2f": "face to face",
-"fubar": "fucked up beyond all recognition",
-"fwiw": "for what it's worth",
-"fyi": "for your information",
-"gmta": "great minds think alike",
-"iam": "in a meeting",
-"ianal": "I am not a lawyer",
-"ihmb": "I hate my boss",
-"iirc": "if I recall correctly",
-"imho": "in my humble opinion",
-"imo": "in my opinion",
-"iow": "in other words",
-"irl": "in real life",
-"<g>": "grin",
-"*g*": "grin",
-"gf": "girlfriend",
-"gmta": "great minds think alike",
-"g2g": "got to go",
-"jid": "jabber identifier",
-"j/k": "just kidding",
-"ok": "okay",
-"lol": "laugh out loud",
-"l8r": "later",
-"msg": "message",
-"n/m": "never mind",
-"n/p": "no problem",
-"oAo": "over and out!",
-"omg": "oh my god",
-"oob": "out of band",
-"otoh": "on the other hand",
-"oww": "oops, wrong window!",
-"otp": "on the phone",
-"pita": "pain in the ass",
-"pov": "point of view",
-"pw": "password",
-"rotfl": "rolling on the floor laughing",
-"rsn": "real soon now",
-"rtfm": "read the friendly manual",
-"slap": "sounds like a plan",
-"thx": "thanks",
-"tia": "thanks in advance",
-"tla": "three-letter arconym",
-"ttfn": "ta ta for now",
-"ttyl": "talk to you later",
-"wb": "welcome back",
-"wfm": "works for me",
-"wtf": "what the fuck?!",
-"wtg": "way to go!",
-"xfer": "transfer",
-"ymmv": "your mileage may vary",}
=====================================
plugins/acronyms_expander/acronyms_expander.py deleted
=====================================
--- a/plugins/acronyms_expander/acronyms_expander.py
+++ /dev/null
@@ -1,110 +0,0 @@
-# -*- coding: utf-8 -*-
-
-## 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/>.
-##
-
-'''
-Acronyms expander plugin.
-
-:author: Mateusz Biliński <mateusz(a)bilinski.it>
-:since: 9th June 2008
-:copyright: Copyright (2008) Mateusz Biliński <mateusz(a)bilinski.it>
-:license: GPL
-'''
-
-import sys
-import os
-
-from gi.repository import Gtk
-from gi.repository import GObject
-
-from gajim.plugins import GajimPlugin
-from gajim.plugins.helpers import log, log_calls
-
-class AcronymsExpanderPlugin(GajimPlugin):
-
- @log_calls('AcronymsExpanderPlugin')
- def init(self):
- self.description = _('Replaces acronyms (or other strings) '
- 'with given expansions/substitutes.')
- self.config_dialog = None
-
- self.gui_extension_points = {
- 'chat_control_base': (self.connect_with_chat_control_base,
- self.disconnect_from_chat_control_base)
- }
-
- self.config_default_values = {
- 'INVOKER': (' ', ''),
- 'ACRONYMS': ({'/slap': '/me slaps',
- 'PS-': 'plug-in system',
- 'G-': 'Gajim',
- 'GNT-': 'https://dev.gajim.org/gajim/gajim/issues',
- 'GW-': 'https://dev.gajim.org/gajim/gajim/wikis/home',
- },
- ''),
- }
- if 'ACRONYMS' not in self.config:
- myAcronyms = self.get_own_acronyms_list()
- self.config['ACRONYMS'].update(myAcronyms)
-
- @log_calls('AcronymsExpanderPlugin')
- def get_own_acronyms_list(self):
- data_file = self.local_file_path('acronyms')
- if not os.path.isfile(data_file):
- return {}
- data = open(data_file, 'r')
- acronyms = eval(data.read())
- data.close()
- return acronyms
-
- @log_calls('AcronymsExpanderPlugin')
- def textbuffer_live_acronym_expander(self, tb):
- """
- @param tb gtk.TextBuffer
- """
- #assert isinstance(tb,gtk.TextBuffer)
- ACRONYMS = self.config['ACRONYMS']
- INVOKER = self.config['INVOKER']
- t = tb.get_text(tb.get_start_iter(), tb.get_end_iter(), True)
- #log.debug('%s %d'%(t, len(t)))
- if t and t[-1] == INVOKER:
- #log.debug('changing msg text')
- base, sep, head=t[:-1].rpartition(INVOKER)
- log.debug('%s | %s | %s'%(base, sep, head))
- if head in ACRONYMS:
- head = ACRONYMS[head]
- #log.debug('head: %s'%(head))
- t = ''.join((base, sep, head, INVOKER))
- #log.debug("setting text: '%s'"%(t))
- GObject.idle_add(tb.set_text, t)
-
- @log_calls('AcronymsExpanderPlugin')
- def connect_with_chat_control_base(self, chat_control):
- d = {}
- tv = chat_control.msg_textview
- tb = tv.get_buffer()
- h_id = tb.connect('changed', self.textbuffer_live_acronym_expander)
- d['h_id'] = h_id
-
- chat_control.acronyms_expander_plugin_data = d
-
- return True
-
- @log_calls('AcronymsExpanderPlugin')
- def disconnect_from_chat_control_base(self, chat_control):
- d = chat_control.acronyms_expander_plugin_data
- tv = chat_control.msg_textview
- tv.get_buffer().disconnect(d['h_id'])
=====================================
plugins/acronyms_expander/manifest.ini deleted
=====================================
--- a/plugins/acronyms_expander/manifest.ini
+++ /dev/null
@@ -1,9 +0,0 @@
-[info]
-name: Acronyms Expander
-short_name: acronyms_expander
-version: 0.1
-description: Replaces acronyms (or other strings) with given expansions/substitutes.
-authors: Mateusz Biliński <mateusz(a)bilinski.it>
-homepage: http://blog.bilinski.it
-
-
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/5aeed6c7376d9ccf0d24c08cca113b49c7…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/5aeed6c7376d9ccf0d24c08cca113b49c7…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
c6fc9081 by Philipp Hörist at 2017-10-14T09:43:44+02:00
Catch exception when closing window
Fixes #8761
- - - - -
1 changed file:
- gajim/roster_window.py
Changes:
=====================================
gajim/roster_window.py
=====================================
--- a/gajim/roster_window.py
+++ b/gajim/roster_window.py
@@ -2381,7 +2381,7 @@ class RosterWindow:
else:
try:
w.window.destroy()
- except AttributeError:
+ except AttributeError, RuntimeError:
w.destroy()
def close_all(self, account, force=False):
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/c6fc9081c5c0dddc68ecb2e4bf9d70b071…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/c6fc9081c5c0dddc68ecb2e4bf9d70b071…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
e79af35e by Philipp Hörist at 2017-10-14T00:13:13+02:00
Refactor store_bookmarks()
- Add logging
- Move Node building code into own methods
- - - - -
149522dc by Philipp Hörist at 2017-10-14T00:13:18+02:00
ServerInfo: Add PubSub discovery
- - - - -
ac281533 by Philipp Hörist at 2017-10-14T00:13:19+02:00
Get Pubsub bookmarks also if PEP is supported
- - - - -
dd4a8005 by Philipp Hörist at 2017-10-14T00:13:19+02:00
Discover PublishOptions also if PubSub is not discovered
PEP supports a subset of PubSub and can also support publish options
- - - - -
fcf15fca by Philipp Hörist at 2017-10-14T00:13:19+02:00
Bookmarks: Remove invalid publish option
- - - - -
4 changed files:
- gajim/common/connection.py
- gajim/common/connection_handlers.py
- gajim/common/pubsub.py
- gajim/server_info.py
Changes:
=====================================
gajim/common/connection.py
=====================================
--- a/gajim/common/connection.py
+++ b/gajim/common/connection.py
@@ -1930,12 +1930,12 @@ class Connection(CommonConnection, ConnectionHandlers):
self.register_supported = True
if nbxmpp.NS_PUBSUB in obj.features:
self.pubsub_supported = True
- if nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS in obj.features:
- self.pubsub_publish_options_supported = True
- else:
- # Remove stored bookmarks accessible to everyone.
- self.send_pb_purge(our_jid, 'storage:bookmarks')
- self.send_pb_delete(our_jid, 'storage:bookmarks')
+ if nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS in obj.features:
+ self.pubsub_publish_options_supported = True
+ else:
+ # Remove stored bookmarks accessible to everyone.
+ self.send_pb_purge(our_jid, 'storage:bookmarks')
+ self.send_pb_delete(our_jid, 'storage:bookmarks')
if nbxmpp.NS_BLOCKING in obj.features:
self.blocking_supported = True
if nbxmpp.NS_ADDRESS in obj.features:
@@ -2347,6 +2347,7 @@ class Connection(CommonConnection, ConnectionHandlers):
iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE)
iq2.addChild(name='storage', namespace='storage:bookmarks')
self.connection.send(iq)
+ app.log('bookmarks').info('Request Bookmarks (PrivateStorage)')
def _check_bookmarks_received(self):
if not self.bookmarks:
@@ -2361,63 +2362,78 @@ class Connection(CommonConnection, ConnectionHandlers):
"""
if not app.account_is_connected(self.name):
return
- if self.pubsub_supported and self.pubsub_publish_options_supported \
- and storage_type != 'xml':
- self.send_pb_retrieve('', 'storage:bookmarks')
- # some server (ejabberd) are so slow to answer that we request via XML
- # if we don't get answer in the next 30 seconds
- app.idlequeue.set_alarm(self._check_bookmarks_received, 30)
- else:
- self._request_bookmarks_xml()
- def store_bookmarks(self, storage_type=None):
- """
- Send bookmarks to the storage namespace or PubSub if supported
+ if storage_type != 'xml':
+ pubsub = self.pubsub_supported or self.pep_supported
+ if pubsub and self.pubsub_publish_options_supported:
+ self.send_pb_retrieve('', 'storage:bookmarks')
+ app.log('bookmarks').info('Request Bookmarks (PubSub)')
+ # some server (ejabberd) are so slow to answer that we
+ # request via XML if we don't get answer in the next 30 seconds
+ app.idlequeue.set_alarm(self._check_bookmarks_received, 30)
+ return
- storage_type can be set to 'pubsub' or 'xml' so store in only one method
- else it will be stored on both
- """
+ self._request_bookmarks_xml()
+
+ def get_bookmarks_storage_node(self):
NS_GAJIM_BM = 'xmpp:gajim.org/bookmarks'
- if not app.account_is_connected(self.name):
- return
- iq = nbxmpp.Node(tag='storage', attrs={'xmlns': 'storage:bookmarks'})
+ storage_node = nbxmpp.Node(
+ tag='storage', attrs={'xmlns': 'storage:bookmarks'})
for bm in self.bookmarks:
- iq2 = iq.addChild(name="conference")
- iq2.setAttr('jid', bm['jid'])
- iq2.setAttr('autojoin', bm['autojoin'])
- iq2.setAttr('name', bm['name'])
- iq2.setTag('minimize', namespace=NS_GAJIM_BM). \
- setData(bm['minimize'])
+ conf_node = storage_node.addChild(name="conference")
+ conf_node.setAttr('jid', bm['jid'])
+ conf_node.setAttr('autojoin', bm['autojoin'])
+ conf_node.setAttr('name', bm['name'])
+ conf_node.setTag(
+ 'minimize', namespace=NS_GAJIM_BM).setData(bm['minimize'])
# Only add optional elements if not empty
# Note: need to handle both None and '' as empty
# thus shouldn't use "is not None"
if bm.get('nick', None):
- iq2.setTagData('nick', bm['nick'])
+ conf_node.setTagData('nick', bm['nick'])
if bm.get('password', None):
- iq2.setTagData('password', bm['password'])
+ conf_node.setTagData('password', bm['password'])
if bm.get('print_status', None):
- iq2.setTag('print_status', namespace=NS_GAJIM_BM). \
- setData(bm['print_status'])
-
- if self.pubsub_supported and self.pubsub_publish_options_supported and\
- storage_type != 'xml':
- options = nbxmpp.Node(nbxmpp.NS_DATA + ' x',
- attrs={'type': 'submit'})
- f = options.addChild('field',
- attrs={'var': 'FORM_TYPE', 'type': 'hidden'})
- f.setTagData('value', nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS)
- f = options.addChild('field',
- attrs={'var': 'pubsub#persist_items'})
- f.setTagData('value', 'true')
- f = options.addChild('field', attrs={'var': 'pubsub#access_model'})
- f.setTagData('value', 'whitelist')
- self.send_pb_publish('', 'storage:bookmarks', iq, 'current',
- options=options)
+ conf_node.setTag(
+ 'print_status',
+ namespace=NS_GAJIM_BM).setData(bm['print_status'])
+ return storage_node
+
+ @staticmethod
+ def get_bookmark_publish_options():
+ options = nbxmpp.Node(nbxmpp.NS_DATA + ' x',
+ attrs={'type': 'submit'})
+ f = options.addChild('field',
+ attrs={'var': 'FORM_TYPE', 'type': 'hidden'})
+ f.setTagData('value', nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS)
+ f = options.addChild('field', attrs={'var': 'pubsub#access_model'})
+ f.setTagData('value', 'whitelist')
+ return options
+
+ def store_bookmarks(self, storage_type=None):
+ """
+ Send bookmarks to the storage namespace or PubSub if supported
+
+ storage_type can be set to 'pubsub' or 'xml' so store in only one method
+ else it will be stored on both
+ """
+ if not app.account_is_connected(self.name):
+ return
+
+ storage_node = self.get_bookmarks_storage_node()
+
+ if storage_type != 'xml':
+ pubsub = self.pubsub_supported or self.pep_supported
+ if pubsub and self.pubsub_publish_options_supported:
+ self.send_pb_publish(
+ '', 'storage:bookmarks', storage_node, 'current',
+ options=self.get_bookmark_publish_options())
+ app.log('bookmarks').info('Bookmarks published (PubSub)')
+
if storage_type != 'pubsub':
- iqA = nbxmpp.Iq(typ='set')
- iqB = iqA.addChild(name='query', namespace=nbxmpp.NS_PRIVATE)
- iqB.addChild(node=iq)
- self.connection.send(iqA)
+ iq = nbxmpp.Iq('set', nbxmpp.NS_PRIVATE, payload=storage_node)
+ self.connection.send(iq)
+ app.log('bookmarks').info('Bookmarks published (PrivateStorage)')
def get_annotations(self):
"""
=====================================
gajim/common/connection_handlers.py
=====================================
--- a/gajim/common/connection_handlers.py
+++ b/gajim/common/connection_handlers.py
@@ -1511,6 +1511,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream):
def _nec_private_storate_bookmarks_received(self, obj):
if obj.conn.name != self.name:
return
+ app.log('bookmarks').info('Received Bookmarks (PrivateStorage)')
resend_to_pubsub = False
bm_jids = [b['jid'] for b in self.bookmarks]
for bm in obj.bookmarks:
@@ -1518,7 +1519,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream):
self.bookmarks.append(bm)
# We got a bookmark that was not in pubsub
resend_to_pubsub = True
- if self.pubsub_supported and resend_to_pubsub:
+ if resend_to_pubsub:
self.store_bookmarks('pubsub')
def _nec_private_storate_rosternotes_received(self, obj):
=====================================
gajim/common/pubsub.py
=====================================
--- a/gajim/common/pubsub.py
+++ b/gajim/common/pubsub.py
@@ -203,6 +203,7 @@ class ConnectionPubSub:
def _nec_pubsub_bookmarks_received(self, obj):
if obj.conn.name != self.name:
return
+ app.log('bookmarks').info('Received Bookmarks (PubSub)')
bm_jids = [b['jid'] for b in self.bookmarks]
for bm in obj.bookmarks:
if bm['jid'] not in bm_jids:
=====================================
gajim/server_info.py
=====================================
--- a/gajim/server_info.py
+++ b/gajim/server_info.py
@@ -118,6 +118,8 @@ class ServerInfoDialog(Gtk.Dialog):
Feature('XEP-0016: Privacy Lists', con.privacy_rules_supported, None),
Feature('XEP-0045: Multi-User Chat', con.muc_jid, None),
Feature('XEP-0054: vcard-temp', con.vcard_supported, None),
+ Feature('XEP-0060: PubSub', con.pubsub_supported, None),
+ Feature('XEP-0060: Publish Options', con.pubsub_publish_options_supported, None),
Feature('XEP-0163: Personal Eventing Protocol', con.pep_supported, None),
Feature('XEP-0191: Blocking Command', con.blocking_supported, nbxmpp.NS_BLOCKING),
Feature('XEP-0198: Stream Management', con.sm.enabled, nbxmpp.NS_STREAM_MGMT),
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/f4a734b70ce4bfdc5346e40306744d3cf…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/f4a734b70ce4bfdc5346e40306744d3cf…
You're receiving this email because of your account on dev.gajim.org.