Exemple #1
0
    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)
Exemple #2
0
    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
Exemple #3
0
    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)
Exemple #4
0
    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
Exemple #5
0
    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)
Exemple #6
0
    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))
Exemple #7
0
    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)
Exemple #8
0
    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])
Exemple #9
0
 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')
Exemple #10
0
    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')
Exemple #11
0
 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)
Exemple #12
0
    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)
Exemple #13
0
    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))
Exemple #14
0
    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()
Exemple #15
0
    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)
Exemple #16
0
    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)
Exemple #17
0
    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)
Exemple #18
0
    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, ))
Exemple #19
0
    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)))
Exemple #20
0
    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)
Exemple #21
0
    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))
Exemple #22
0
    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)
Exemple #23
0
    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
Exemple #24
0
    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)
Exemple #25
0
    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)
Exemple #26
0
    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))
Exemple #27
0
    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)
Exemple #28
0
    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)
Exemple #29
0
    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')
Exemple #30
0
    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'))