diff --git a/gajim/chat_control.py b/gajim/chat_control.py
index f3c7975e2..6fdfcad0e 100644
--- a/gajim/chat_control.py
+++ b/gajim/chat_control.py
@@ -1482,12 +1482,12 @@ class ChatControl(ChatControlBase):
self._add_info_bar_message(markup, [b], file_props, Gtk.MessageType.ERROR)
def _on_accept_gc_invitation(self, widget, event):
- if event.is_continued:
- app.interface.join_gc_room(self.account, event.room_jid,
+ if event.continued:
+ app.interface.join_gc_room(self.account, str(event.muc),
app.nicks[self.account], event.password,
is_continued=True)
else:
- app.interface.join_gc_minimal(self.account, event.room_jid)
+ app.interface.join_gc_minimal(self.account, str(event.muc))
app.events.remove_events(self.account, self.contact.jid, event=event)
@@ -1495,14 +1495,14 @@ class ChatControl(ChatControlBase):
app.events.remove_events(self.account, self.contact.jid, event=event)
def _get_gc_invitation(self, event):
- markup = '%s: %s' % (_('Groupchat Invitation'), event.room_jid)
+ markup = '%s: %s' % (_('Groupchat Invitation'), event.muc)
if event.reason:
markup += ' (%s)' % event.reason
b1 = Gtk.Button.new_with_mnemonic(_('_Join'))
b1.connect('clicked', self._on_accept_gc_invitation, event)
b2 = Gtk.Button(stock=Gtk.STOCK_CANCEL)
b2.connect('clicked', self._on_cancel_gc_invitation, event)
- self._add_info_bar_message(markup, [b1, b2], (event.room_jid,
+ self._add_info_bar_message(markup, [b1, b2], (event.muc,
event.reason), Gtk.MessageType.QUESTION)
def on_event_added(self, event):
@@ -1546,7 +1546,7 @@ class ChatControl(ChatControlBase):
removed = False
for ib_msg in self.info_bar_queue:
if ev.type_ == 'gc-invitation':
- if ev.room_jid == ib_msg[2][0]:
+ if ev.muc == ib_msg[2][0]:
self.info_bar_queue.remove(ib_msg)
removed = True
else: # file-*
diff --git a/gajim/common/app.py b/gajim/common/app.py
index d849b7e9b..d693d4d55 100644
--- a/gajim/common/app.py
+++ b/gajim/common/app.py
@@ -480,6 +480,7 @@ def zeroconf_is_connected():
config.get_per('accounts', ZEROCONF_ACC_NAME, 'is_zeroconf')
def in_groupchat(account, room_jid):
+ room_jid = str(room_jid)
if room_jid not in gc_connected[account]:
return False
return gc_connected[account][room_jid]
diff --git a/gajim/common/contacts.py b/gajim/common/contacts.py
index 63b2d3363..da084ae32 100644
--- a/gajim/common/contacts.py
+++ b/gajim/common/contacts.py
@@ -307,12 +307,12 @@ class LegacyContactsAPI:
return self_contact
def create_not_in_roster_contact(self, jid, account, resource='', name='',
- keyID=''):
+ keyID='', groupchat=False):
# Use Account object if available
account = self._accounts.get(account, account)
return self.create_contact(jid=jid, account=account, resource=resource,
name=name, groups=[_('Not in Roster')], show='not in roster',
- status='', sub='none', keyID=keyID)
+ status='', sub='none', keyID=keyID, groupchat=groupchat)
def copy_contact(self, contact):
return self.create_contact(contact.jid, contact.account,
diff --git a/gajim/common/events.py b/gajim/common/events.py
index 372c092ab..a33da82bc 100644
--- a/gajim/common/events.py
+++ b/gajim/common/events.py
@@ -130,15 +130,10 @@ class UnsubscribedEvent(Event):
class GcInvitationtEvent(Event):
type_ = 'gc-invitation'
- def __init__(self, room_jid, reason, password, is_continued, jid_from,
- time_=None, show_in_roster=False, show_in_systray=True):
- Event.__init__(self, time_, show_in_roster=show_in_roster,
- show_in_systray=show_in_systray)
- self.room_jid = room_jid
- self.reason = reason
- self.password = password
- self.is_continued = is_continued
- self.jid_from = jid_from
+ def __init__(self, event):
+ Event.__init__(self, None, show_in_roster=False, show_in_systray=True)
+ for key, value in vars(event).items():
+ setattr(self, key, value)
class FileRequestEvent(Event):
type_ = 'file-request'
diff --git a/gajim/common/helpers.py b/gajim/common/helpers.py
index 269332921..7ededa758 100644
--- a/gajim/common/helpers.py
+++ b/gajim/common/helpers.py
@@ -1462,6 +1462,15 @@ def load_json(path, key=None, default=None):
return json_dict
return json_dict.get(key, default)
+def ignore_contact(account, jid):
+ jid = str(jid)
+ known_contact = app.contacts.get_contacts(account, jid)
+ ignore = app.config.get_per('accounts', account, 'ignore_unknown_contacts')
+ if ignore and not known_contact:
+ log.info('Ignore unknown contact %s', jid)
+ return True
+ return False
+
class AdditionalDataDict(collections.UserDict):
def __init__(self, initialdata=None):
collections.UserDict.__init__(self, initialdata)
diff --git a/gajim/common/modules/bits_of_binary.py b/gajim/common/modules/bits_of_binary.py
index 2bae0eb39..37745ac1e 100644
--- a/gajim/common/modules/bits_of_binary.py
+++ b/gajim/common/modules/bits_of_binary.py
@@ -170,5 +170,29 @@ def parse_bob_data(stanza):
return filepath
+def store_bob_data(bob_data):
+ if bob_data is None:
+ return
+
+ algo_hash = '%s+%s' % (bob_data.algo, bob_data.hash_)
+
+ filepath = Path(configpaths.get('BOB')) / algo_hash
+ if algo_hash in app.bob_cache or filepath.exists():
+ log.info('BoB data already cached')
+ return
+
+ if bob_data.max_age == 0:
+ app.bob_cache[algo_hash] = bob_data.data
+ else:
+ try:
+ with open(str(filepath), 'w+b') as file:
+ file.write(bob_data.data)
+ except Exception:
+ log.exception('Unable to save data')
+ return
+ log.info('BoB data stored: %s', algo_hash)
+ return filepath
+
+
def get_instance(*args, **kwargs):
return BitsOfBinary(*args, **kwargs), 'BitsOfBinary'
diff --git a/gajim/common/modules/message.py b/gajim/common/modules/message.py
index 3f3e601b5..c301cd213 100644
--- a/gajim/common/modules/message.py
+++ b/gajim/common/modules/message.py
@@ -212,31 +212,14 @@ class Message:
subject = event.stanza.getSubject()
groupchat = event.mtype == 'groupchat'
- # XEP-0045: only a message that contains a but no