Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _server_items_info_received(self, result):
if is_error_result(result):
self._log.warning('Server item disco info failed')
self._log.warning(result)
return
self._log.info('Server item info received: %s', result.jid)
self._parse_transports(result)
try:
self._con.get_module('MUC').pass_disco(result)
self._con.get_module('HTTPUpload').pass_disco(result)
self._con.get_module('Bytestream').pass_disco(result)
except nbxmpp.NodeProcessed:
pass
app.nec.push_incoming_event(
NetworkIncomingEvent('server-disco-received'))
def set_os_info(self, result, jid):
if self.xml.get_object('information_notebook').get_n_pages() < 5:
return
error = is_error_result(result)
i = 0
client = ''
os_info = ''
while i in self.os_info:
if self.os_info[i]['resource'] == JID(jid).getResource():
if not error:
self.os_info[i]['client'] = '%s %s' % (result.name,
result.version)
else:
self.os_info[i]['client'] = Q_('?Client:Unknown')
if not error and result.os is not None:
self.os_info[i]['os'] = result.os
else:
self.os_info[i]['os'] = Q_('?OS:Unknown')
def _disco_info_received(self, result):
if is_error_result(result):
if result.condition == 'item-not-found':
self._create_muc(result.jid)
return
self._set_warning_from_error(result)
else:
self._set_warning_from_error_code(
'already-exists' if result.is_muc else 'not-muc-service')
self._set_processing_state(False)
def _server_items_received(self, result):
if is_error_result(result):
self._log.warning('Server disco failed')
self._log.error(result)
return
self._log.info('Server items received')
self._log.debug(result)
for item in result.items:
if item.node is not None:
# Only disco components
continue
self.disco_info(item.jid, callback=self._server_items_info_received)
def _received_slot(self, result, transfer):
if is_error_result(result):
transfer.set_error()
if result.app_condition == 'file-too-large':
size_text = GLib.format_size_full(
result.get_max_file_size(),
GLib.FormatSizeFlags.IEC_UNITS)
error_text = _('File is too large, '
'maximum allowed file size is: %s' % size_text)
else:
error_text = str(result)
self._log.warning(result)
self._raise_information_event('request-upload-slot-error',
error_text)
return
def _on_change_password(self, result):
if is_error_result(result):
error_text = to_user_string(result)
self.get_page('error').set_text(error_text)
self.show_page('error', Gtk.StackTransitionType.SLIDE_LEFT)
elif result.successful:
self.show_page('success')
else:
self.get_page('next_stage').set_form(result.form)
self.show_page('next_stage', Gtk.StackTransitionType.SLIDE_LEFT)
def _result_finished(self, result, user_data):
queryid, start_date, groupchat = user_data.values()
self._remove_query_id(result.jid)
if is_error_result(result):
if result.condition == 'item-not-found':
app.logger.reset_archive_infos(result.jid)
if groupchat:
self.request_archive_on_muc_join(result.jid)
else:
self.request_archive_on_signin()
return
if result.complete:
self._catch_up_finished.append(result.jid)
self._log.info('Request finished: %s, last mam id: %s',
result.jid, result.rsm.last)
if result.rsm.last is not None:
# is not provided if the requested page was empty
# so this means we did not get anything hence we only need
def _on_data_result(self, result, file_props):
if is_error_result(result):
app.socks5queue.error_cb('Error', to_user_string(result))
self._log.warning(result)
return
self.send_data(file_props)
def _on_interval_result(self, result, user_data):
queryid, start_date, end_date = user_data.values()
self._remove_query_id(result.jid)
if is_error_result(result):
return
if start_date:
timestamp = start_date.timestamp()
else:
timestamp = ArchiveState.ALL
if result.complete:
self._log.info('Request finished: %s, last mam id: %s',
result.jid, result.rsm.last)
app.logger.set_archive_infos(result.jid,
oldest_mam_timestamp=timestamp)
app.nec.push_incoming_event(NetworkEvent(
'archiving-interval-finished',
account=self._account,
query_id=queryid))
def _on_close_result(self, result):
if is_error_result(result):
app.socks5queue.error_cb('Error', to_user_string(result))
self._log.warning(result)
return