Exemplo n.º 1
0
    def _send_presence(self, muc_data, auto):
        show = app.SHOW_LIST[self._con.connected]
        if show in ('invisible', 'offline'):
            # FIXME: Check if this
            return

        status = self._con.status

        xmpp_show = helpers.get_xmpp_show(show)

        idle_time = None
        if auto and app.is_installed('IDLE') and app.config.get('autoaway'):
            idle_sec = idle.Monitor.get_idle_sec()
            idle_time = time.strftime('%Y-%m-%dT%H:%M:%SZ',
                                      time.gmtime(time.time() - idle_sec))

        self._log.info(
            'Send presence: %s, show: %s, status: %s, idle_time: %s',
            muc_data.occupant_jid, xmpp_show, status, idle_time)

        self._con.get_module('Presence').send_presence(muc_data.occupant_jid,
                                                       show=xmpp_show,
                                                       status=status,
                                                       caps=True,
                                                       idle_time=idle_time)
Exemplo n.º 2
0
    def _create(self, muc_data):
        show = helpers.get_xmpp_show(app.SHOW_LIST[self._con.connected])

        presence = self._con.get_module('Presence').get_presence(
            muc_data.occupant_jid, show=show, status=self._con.status)

        presence.setTag(nbxmpp.NS_MUC + ' x')

        self._log.info('Create MUC: %s', muc_data.jid)
        self._manager.set_state(muc_data.jid, MUCJoinedState.CREATING)
        self._con.connection.send(presence)
Exemplo n.º 3
0
 def send_avatar_presence(self, force=False):
     if self.avatar_advertised and not force:
         log.debug('Avatar already advertised')
         return
     show = helpers.get_xmpp_show(app.SHOW_LIST[self._con.connected])
     pres = nbxmpp.Presence(typ=None,
                            priority=self._con.priority,
                            show=show,
                            status=self._con.status)
     pres = self._con.add_sha(pres)
     self._con.connection.send(pres)
     self.avatar_advertised = True
     app.interface.update_avatar(self._account,
                                 self._con.get_own_jid().getStripped())
Exemplo n.º 4
0
    def _join(self, muc_data):
        show = helpers.get_xmpp_show(app.SHOW_LIST[self._con.connected])

        presence = self._con.get_module('Presence').get_presence(
            muc_data.occupant_jid, show=show, status=self._con.status)

        muc_x = presence.setTag(nbxmpp.NS_MUC + ' x')
        self._add_history_query(muc_x, str(muc_data.jid))

        if muc_data.password is not None:
            muc_x.setTagData('password', muc_data.password)

        self._log.info('Join MUC: %s', muc_data.jid)
        self._manager.set_state(muc_data.jid, MUCJoinedState.JOINING)
        self._con.connection.send(presence)
Exemplo n.º 5
0
    def send_avatar_presence(self, force=False, after_publish=False):
        if self._con.avatar_conversion:
            if not after_publish:
                # XEP-0398: We only resend presence after we publish a
                # new avatar
                return
        else:
            if self.avatar_advertised and not force:
                self._log.debug('Avatar already advertised')
                return

        show = helpers.get_xmpp_show(app.SHOW_LIST[self._con.connected])

        self._con.get_module('Presence').send_presence(
            priority=self._con.priority, show=show, status=self._con.status)

        self.avatar_advertised = True
    def _send_first_presence(self, signed=''):
        show = self.continue_connect_info[0]
        msg = self.continue_connect_info[1]
        sign_msg = self.continue_connect_info[2]
        if sign_msg and not signed:
            signed = self.get_signed_presence(msg)
            if signed is None:
                app.nec.push_incoming_event(
                    BadGPGPassphraseEvent(None, conn=self))
                self.USE_GPG = False
                signed = ''
        self.connected = app.SHOW_LIST.index(show)
        sshow = helpers.get_xmpp_show(show)
        # send our presence
        if show == 'invisible':
            self.send_invisible_presence(msg, signed, True)
            return
        if show not in ['offline', 'online', 'chat', 'away', 'xa', 'dnd']:
            return
        priority = app.get_priority(self.name, sshow)
        p = nbxmpp.Presence(typ=None, priority=priority, show=sshow)
        if msg:
            p.setStatus(msg)
        if signed:
            p.setTag(nbxmpp.NS_SIGNED + ' x').setData(signed)
        p = self.add_sha(p)

        if self.connection:
            self.connection.send(p)
            self.priority = priority
        app.nec.push_incoming_event(OurShowEvent(None, conn=self, show=show))

        # ask our VCard
        self.get_module('VCardTemp').request_vcard()

        # Get bookmarks
        self.get_module('Bookmarks').get_bookmarks()

        # Get annotations from private namespace
        self.get_module('Annotations').get_annotations()

        # Inform GUI we just signed in
        app.nec.push_incoming_event(SignedInEvent(None, conn=self))
        self.get_module('PEP').send_stored_publish()
        self.continue_connect_info = None
Exemplo n.º 7
0
 def change_nick(self, room_jid, new_nick):
     show = helpers.get_xmpp_show(app.SHOW_LIST[self._con.connected])
     self._con.get_module('Presence').send_presence('%s/%s' %
                                                    (room_jid, new_nick),
                                                    show=show,
                                                    status=self._con.status)