コード例 #1
0
ファイル: handlers.py プロジェクト: Perdu/poezio
def on_session_start(self, event):
    """
    Called when we are connected and authenticated
    """
    self.connection_time = time.time()
    if not self.plugins_autoloaded: # Do not reload plugins on reconnection
        self.autoload_plugins()
    self.information(_("Authentication success."), 'Info')
    self.information(_("Your JID is %s") % self.xmpp.boundjid.full, 'Info')
    if not self.xmpp.anon:
        # request the roster
        self.xmpp.get_roster()
        roster.update_contact_groups(self.xmpp.boundjid.bare)
        # send initial presence
        if config.get('send_initial_presence'):
            pres = self.xmpp.make_presence()
            pres['show'] = self.status.show
            pres['status'] = self.status.message
            self.events.trigger('send_normal_presence', pres)
            pres.send()
    bookmark.get_local()
    def _join_initial_rooms(bookmarks):
        """Join all rooms given in the iterator `bookmarks`"""
        for bm in bookmarks:
            if bm.autojoin or config.get('open_all_bookmarks'):
                tab = self.get_tab_by_name(bm.jid, tabs.MucTab)
                nick = bm.nick if bm.nick else self.own_nick
                if not tab:
                    self.open_new_room(bm.jid, nick, False)
                self.initial_joins.append(bm.jid)
                histo_length = config.get('muc_history_length')
                if histo_length == -1:
                    histo_length = None
                if histo_length is not None:
                    histo_length = str(histo_length)
                # do not join rooms that do not have autojoin
                # but display them anyway
                if bm.autojoin:
                    muc.join_groupchat(self, bm.jid, nick,
                            passwd=bm.password,
                            maxhistory=histo_length,
                            status=self.status.message,
                            show=self.status.show)
    def _join_remote_only():
        remote_bookmarks = (bm for bm in bookmark.bookmarks if (bm.method in ("pep", "privatexml")))
        _join_initial_rooms(remote_bookmarks)
    if not self.xmpp.anon and config.get('use_remote_bookmarks'):
        bookmark.get_remote(self.xmpp, _join_remote_only)
    # join all the available bookmarks. As of yet, this is just the local
    # ones
    _join_initial_rooms(bookmark.bookmarks)

    if config.get('enable_user_nick'):
        self.xmpp.plugin['xep_0172'].publish_nick(nick=self.own_nick, callback=dumb_callback)
    self.xmpp.plugin['xep_0115'].update_caps()
    # Start the ping's plugin regular event
    self.xmpp.set_keepalive_values()
コード例 #2
0
ファイル: handlers.py プロジェクト: Perdu/poezio
def on_roster_update(self, iq):
    """
    The roster was received.
    """
    for item in iq['roster']:
        try:
            jid = item['jid']
        except InvalidJID:
            jid = item._get_attr('jid', '')
            log.error('Invalid JID: "%s"', jid, exc_info=True)
        else:
            if item['subscription'] == 'remove':
                del roster[jid]
            else:
                roster.update_contact_groups(jid)
    if isinstance(self.current_tab(), tabs.RosterInfoTab):
        self.refresh_window()
コード例 #3
0
ファイル: handlers.py プロジェクト: Perdu/poezio
def on_subscription_request(self, presence):
    """subscribe received"""
    jid = presence['from'].bare
    contact = roster[jid]
    if contact and contact.subscription in ('from', 'both'):
        return
    elif contact and contact.subscription == 'to':
        self.xmpp.sendPresence(pto=jid, ptype='subscribed')
        self.xmpp.sendPresence(pto=jid)
    else:
        if not contact:
            contact = roster.get_and_set(jid)
        roster.update_contact_groups(contact)
        contact.pending_in = True
        self.information('%s wants to subscribe to your presence' % jid, 'Roster')
        self.get_tab_by_number(0).state = 'highlight'
        roster.modified()
    if isinstance(self.current_tab(), tabs.RosterInfoTab):
        self.refresh_window()
コード例 #4
0
ファイル: rostertab.py プロジェクト: fmeynadier/poezio
 def callback(iq):
     if iq:
         roster.update_contact_groups(jid)
     else:
         self.core.information('The group could not be set')
         log.debug('Error in groupremove:\n%s', iq)
コード例 #5
0
ファイル: rostertab.py プロジェクト: Perdu/poezio
 def callback(iq):
     if iq:
         roster.update_contact_groups(jid)
     else:
         self.core.information('The group could not be set')
         log.debug('Error in groupremove:\n%s', iq)