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 transfer.process_result(result) if (urlparse(transfer.put_uri).scheme != 'https' or urlparse(transfer.get_uri).scheme != 'https'): transfer.set_error() self._raise_information_event('unsecure-error') return self._log.info('Uploading file to %s', transfer.put_uri) self._log.info('Please download from %s', transfer.get_uri) self._upload_file(transfer)
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') if i > 0: client += '\n' os_info += '\n' client += self.os_info[i]['client'] os_info += self.os_info[i]['os'] i += 1 self.xml.get_object('client_name_version_label').set_text(client) self.xml.get_object('os_label').set_text(os_info) self.os_info_arrived = True
def _on_config_result(self, result): if is_error_result(result): self._log.info(result) app.nec.push_incoming_event( NetworkEvent('muc-configuration-failed', account=self._account, room_jid=result.jid, error=result)) return self._con.get_module('Discovery').disco_muc( result.jid, callback=self._on_disco_result_after_config) # If this is an automatic room creation try: invites = app.automatic_rooms[self._account][ result.jid]['invities'] except KeyError: return user_list = {} for jid in invites: user_list[jid] = {'affiliation': 'member'} self.set_affiliation(result.jid, user_list) for jid in invites: self.invite(result.jid, jid)
def _disco_info_received(self, result): if is_error_result(result): ErrorDialog(_('Wrong server'), _('%s is not a group chat server') % result.jid, transient_for=self) return if nbxmpp.NS_MUC not in result.features: ErrorDialog(_('Wrong server'), _('%s is not a group chat server') % result.jid, transient_for=self) return jid = str(result.jid) if jid in app.interface.instances[self.account]['disco']: app.interface.instances[self.account]['disco'][jid].window.\ present() else: try: # Object will add itself to the window dict ServiceDiscoveryWindow(self.account, jid, initial_identities=[ DiscoIdentity(category='conference', type='text', name=None) ]) except GajimGeneralException: pass
def _public_key_received(self, result, fingerprint): if is_error_result(result): log.error('%s => Public Key not found: %s', self._account, result) return imported_key = self._pgp.import_key(result.key, result.jid) if imported_key is not None: self._contacts.set_public_key(result.jid, fingerprint)
def _blocking_list_received(self, result): if is_error_result(result): self._log.info(result) return self.blocked = result.blocking_list app.nec.push_incoming_event( BlockingEvent(None, conn=self._con, changed=self.blocked))
def _keylist_received(self, result, jid): if is_error_result(result): log.error('%s => Keylist query failed: %s', self._account, result) if self.own_jid.bareMatch(jid) and self._fingerprint is not None: self.set_keylist() return log.info('Keylist received from %s', jid) self._process_keylist(result, jid)
def _items_received(self, result): if is_error_result(result): ErrorDialog('Error', to_user_string(result)) return jid = result.jid.getBare() for item in result.items: if item.jid == jid and item.node is not None: self.treestore.append([item.node])
def _on_remove_response(self, result): if is_error_result(result): self._con.removing_account = False error_text = to_user_string(result) self.get_page('error').set_text(error_text) self.show_page('error') else: app.interface.remove_account(self.account) self.show_page('success')
def _disco_info_received(self, result): if is_error_result(result): self._set_error(result) elif result.is_muc: self._muc_info_box.set_from_disco_info(result) self._stack.set_visible_child_name('info') else: self._set_error_from_code('not-muc-service')
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 _parameters_received(self, result, user_data): if is_error_result(result): self._global_search_listbox.remove_progress() self._show_error_page(to_user_string(result)) return con, text = user_data self._parameter_form = result self._parameter_form.type_ = 'submit' self._start_iq_search(con, text)
def _bookmarks_received(self, bookmarks): if is_error_result(bookmarks): self._log.info('Error: %s', bookmarks) bookmarks = [] self._request_in_progress = False self._bookmarks = bookmarks self.auto_join_bookmarks() app.nec.push_incoming_event( NetworkEvent('bookmarks-received', account=self._account))
def _on_save_result(self, result): self._await_results -= 1 if is_error_result(result) and not self._received_errors: self._show_error(to_user_string(result)) self._received_errors = True if not self._await_results: if self._received_errors: self._reset_after_error() else: self.destroy()
def _disco_info_received(self, result): if is_error_result(result): if result.type == '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 _muc_info_received(self, result, callback=None): self._log.info('MUC info received: %s', result.jid) if not is_error_result(result): app.logger.set_last_disco_info(result.jid, result) self._con.get_module('VCardAvatars').muc_disco_info_update(result) app.nec.push_incoming_event( NetworkEvent('muc-disco-update', account=self._account, room_jid=result.jid)) if callback is not None: callback(result)
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 _on_blocking_list_received(self, result): is_error = is_error_result(result) self._disable_spinner() self._set_grid_state(not is_error) if is_error: self._show_error(to_user_string(result)) else: self._prev_blocked_jids = set(result.blocking_list) self._ui.blocking_store.clear() for item in result.blocking_list: self._ui.blocking_store.append((item, ))
def _on_captcha_result(self, result): if not is_error_result(result): return muc_data = self._manager.get(result.jid) if muc_data is None: return self._manager.set_state(result.jid, MUCJoinedState.CAPTCHA_FAILED) app.nec.push_incoming_event( NetworkEvent('muc-captcha-error', account=self._account, room_jid=str(result.jid), error_text=to_user_string(result)))
def _on_affiliations_received(self, result, room_jid): if is_error_result(result): self._log.info('Affiliation request failed: %s', result) return for user_jid in result.users: jid = str(user_jid) self.backend.add_muc_member(room_jid, jid) if not self.is_contact_in_roster(jid): # Query Devicelists from JIDs not in our Roster self._log.info('%s not in Roster, query devicelist...', jid) self.request_devicelist(jid)
def _on_disco_result_after_config(self, result): if is_error_result(result): self._log.info('Disco %s failed: %s', result.jid, result.get_text()) return muc_data = self._manager.get(result.jid) self._room_join_complete(muc_data) self._log.info('Configuration finished: %s', result.jid) app.nec.push_incoming_event( NetworkEvent('muc-configuration-finished', account=self._account, room_jid=result.jid))
def _received_stage(self, stage): if is_error_result(stage): self.get_nth_page(Page.ERROR).set_text(str(stage)) self.get_nth_page(Page.ERROR).show_command_button = True self.set_current_page(Page.ERROR) return page = Page.STAGE if stage.is_completed: page = Page.COMPLETED stage_page = self.get_nth_page(page) stage_page.process_stage(stage) self.set_current_page(page)
def _account_info_received(self, result): if is_error_result(result): self._log.warning('Account disco info failed') self._log.warning(result) return self._log.info('Account info received: %s', result.jid) self._con.get_module('MAM').pass_disco(result) self._con.get_module('PEP').pass_disco(result) self._con.get_module('PubSub').pass_disco(result) self._con.get_module('Bookmarks').pass_disco(result) if 'urn:xmpp:pep-vcard-conversion:0' in result.features: self._con.avatar_conversion = True
def _received_command_list(self, commands): error_text = None if is_error_result(commands): error_text = str(commands) elif not commands: error_text = _('No commands available') if error_text is not None: self.get_nth_page(Page.ERROR).set_text(error_text) self.get_nth_page(Page.ERROR).show_command_button = False self.set_current_page(Page.ERROR) return self.get_nth_page(Page.COMMANDS).add_commands(commands) self.set_current_page(Page.COMMANDS)
def _parameters_received(self, result, user_data): if is_error_result(result): self._global_search_listbox.remove_progress() self._show_error_page(result.message) return con, text = user_data self._parameter_form = result self._parameter_form.type_ = 'submit' self._parameter_form.vars['q'].value = text con.get_module('Muclumbus').set_search( app.config.get('muclumbus_api_jid'), self._parameter_form, callback=self._on_search_result, user_data=con)
def _avatar_received(self, result): if is_error_result(result): self._log.info('Error: %s', result) return self._log.info('Received Avatar: %s %s', result.jid, result.sha) app.interface.save_avatar(result.data) if self._con.get_own_jid().bareMatch(result.jid): app.config.set_per('accounts', self._account, 'avatar_sha', result.sha) else: own_jid = self._con.get_own_jid().getBare() app.logger.set_avatar_sha(own_jid, str(result.jid), result.sha) app.contacts.set_avatar(self._account, str(result.jid), result.sha) app.interface.update_avatar(self._account, str(result.jid))
def _on_disco_result(self, result): if is_error_result(result): self._log.info('Disco %s failed: %s', result.jid, result.get_text()) app.nec.push_incoming_event( NetworkEvent('muc-join-failed', account=self._account, room_jid=result.jid.getBare(), error=result)) return muc_data = self._manager.get(result.jid) if muc_data is None: self._log.warning('MUC Data not found, join aborted') return self._join(muc_data)
def _on_room_config(self, result): if is_error_result(result): self._log.info(result) app.nec.push_incoming_event( NetworkEvent('muc-configuration-failed', account=self._account, room_jid=result.jid, error=result)) return self._log.info('Configure room: %s', result.jid) muc_data = self._manager.get(result.jid) self._apply_config(result.form, muc_data.config) self.set_config(result.jid, result.form, callback=self._on_config_result)
def _disco_info_received(self, account, result): if is_error_result(result): jid = get_alternative_venue(result) if jid is None or self._redirected: self._set_error(result) return self._redirected = True self._disco_muc(account, jid) elif result.is_muc: self._muc_info_box.set_account(account) self._muc_info_box.set_from_disco_info(result) self._ui.stack.set_visible_child_name('info') else: self._set_error_from_code('not-muc-service')
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'))