Beispiel #1
0
def completion_message(self, the_input):
    """Completion for /message"""
    n = the_input.get_argument_position(quoted=True)
    if n >= 2:
        return
    comp = reduce(lambda x, y: x + [i.jid for i in y], (roster[jid].resources for jid in roster.jids() if len(roster[jid])), [])
    comp = sorted(comp)
    bares = sorted(roster[contact].bare_jid for contact in roster.jids() if len(roster[contact]))
    off = sorted(jid for jid in roster.jids() if jid not in bares)
    comp = bares + comp + off
    return the_input.new_completion(comp, 1, '', quotify=True)
Beispiel #2
0
def completion_message(self, the_input):
    """Completion for /message"""
    n = the_input.get_argument_position(quoted=True)
    if n >= 2:
        return
    comp = reduce(lambda x, y: x + [i.jid for i in y],
                  (roster[jid].resources
                   for jid in roster.jids() if len(roster[jid])), [])
    comp = sorted(comp)
    bares = sorted(roster[contact].bare_jid for contact in roster.jids()
                   if len(roster[contact]))
    off = sorted(jid for jid in roster.jids() if jid not in bares)
    comp = bares + comp + off
    return the_input.new_completion(comp, 1, '', quotify=True)
Beispiel #3
0
 def completion_block(self, the_input):
     """
     Completion for /block
     """
     if the_input.get_argument_position() == 1:
         jids = roster.jids()
         return the_input.new_completion(jids, 1, '', quotify=False)
Beispiel #4
0
 def completion_name(self, the_input):
     """Completion for /name"""
     n = the_input.get_argument_position()
     if n == 1:
         jids = [jid for jid in roster.jids()]
         return the_input.new_completion(jids, n, quotify=True)
     return False
Beispiel #5
0
 def completion_name(self, the_input):
     """Completion for /name"""
     n = the_input.get_argument_position()
     if n == 1:
         jids = [jid for jid in roster.jids()]
         return the_input.new_completion(jids, n, quotify=True)
     return False
Beispiel #6
0
 def completion_block(self, the_input):
     """
     Completion for /block
     """
     if the_input.get_argument_position() == 1:
         jids = roster.jids()
         return the_input.new_completion(jids, 1, '', quotify=False)
Beispiel #7
0
def completion_invite(self, the_input):
    """Completion for /invite"""
    n = the_input.get_argument_position(quoted=True)
    if n == 1:
        comp = reduce(lambda x, y: x + [i.jid for i in y], (roster[jid].resources for jid in roster.jids() if len(roster[jid])), [])
        comp = sorted(comp)
        bares = sorted(roster[contact].bare_jid for contact in roster.jids() if len(roster[contact]))
        off = sorted(jid for jid in roster.jids() if jid not in bares)
        comp = comp + bares + off
        return the_input.new_completion(comp, n, quotify=True)
    elif n == 2:
        rooms = []
        for tab in self.get_tabs(tabs.MucTab):
            if tab.joined:
                rooms.append(tab.name)
        rooms.sort()
        return the_input.new_completion(rooms, n, '', quotify=True)
Beispiel #8
0
def completion_presence(self, the_input):
    """
    Completion of /presence
    """
    arg = the_input.get_argument_position()
    if arg == 1:
        return the_input.auto_completion([jid for jid in roster.jids()], "", quotify=True)
    elif arg == 2:
        return the_input.auto_completion([status for status in possible_show], "", quotify=True)
Beispiel #9
0
 def completion_groupadd(self, the_input):
     n = the_input.get_argument_position()
     if n == 1:
         jids = sorted(jid for jid in roster.jids())
         return the_input.new_completion(jids, n, '', quotify=True)
     elif n == 2:
         groups = sorted(group for group in roster.groups if group != 'none')
         return the_input.new_completion(groups, n, '', quotify=True)
     return False
Beispiel #10
0
 def completion_groupadd(self, the_input):
     n = the_input.get_argument_position()
     if n == 1:
         jids = sorted(jid for jid in roster.jids())
         return the_input.new_completion(jids, n, '', quotify=True)
     elif n == 2:
         groups = sorted(group for group in roster.groups
                         if group != 'none')
         return the_input.new_completion(groups, n, '', quotify=True)
     return False
Beispiel #11
0
def completion_invite(self, the_input):
    """Completion for /invite"""
    n = the_input.get_argument_position(quoted=True)
    if n == 1:
        comp = reduce(lambda x, y: x + [i.jid for i in y],
                      (roster[jid].resources
                       for jid in roster.jids() if len(roster[jid])), [])
        comp = sorted(comp)
        bares = sorted(roster[contact].bare_jid for contact in roster.jids()
                       if len(roster[contact]))
        off = sorted(jid for jid in roster.jids() if jid not in bares)
        comp = comp + bares + off
        return the_input.new_completion(comp, n, quotify=True)
    elif n == 2:
        rooms = []
        for tab in self.get_tabs(tabs.MucTab):
            if tab.joined:
                rooms.append(tab.name)
        rooms.sort()
        return the_input.new_completion(rooms, n, '', quotify=True)
Beispiel #12
0
def completion_last_activity(self, the_input):
    """
    Completion for /last_activity <jid>
    """
    n = the_input.get_argument_position(quoted=False)
    if n >= 2:
        return
    comp = reduce(lambda x, y: x + [i.jid for i in y],
                  (roster[jid].resources
                   for jid in roster.jids() if len(roster[jid])), [])
    return the_input.new_completion(sorted(comp), 1, '', quotify=False)
Beispiel #13
0
def completion_last_activity(self, the_input):
    """
    Completion for /last_activity <jid>
    """
    n = the_input.get_argument_position(quoted=False)
    if n >= 2:
        return
    comp = reduce(
        lambda x, y: x + [i.jid for i in y], (roster[jid].resources for jid in roster.jids() if len(roster[jid])), []
    )
    return the_input.new_completion(sorted(comp), 1, "", quotify=False)
Beispiel #14
0
def completion_message(self, the_input):
    """Completion for /message"""
    n = the_input.get_argument_position(quoted=True)
    if n >= 2:
        return
    l = []
    for jid in roster.jids():
        if len(roster[jid]):
            l.append(jid)
            for resource in roster[jid].resources:
                l.append(resource.jid)
    return the_input.new_completion(l, 1, "", quotify=True)
Beispiel #15
0
def completion_presence(self, the_input):
    """
    Completion of /presence
    """
    arg = the_input.get_argument_position()
    if arg == 1:
        return the_input.auto_completion([jid for jid in roster.jids()],
                                         '',
                                         quotify=True)
    elif arg == 2:
        return the_input.auto_completion([status for status in possible_show],
                                         '',
                                         quotify=True)
Beispiel #16
0
 def completion_groupremove(self, the_input):
     args = common.shell_split(the_input.text)
     n = the_input.get_argument_position()
     if n == 1:
         jids = sorted(jid for jid in roster.jids())
         return the_input.new_completion(jids, n, '', quotify=True)
     elif n == 2:
         contact = roster[args[1]]
         if contact is None:
             return False
         groups = sorted(contact.groups)
         try:
             groups.remove('none')
         except ValueError:
             pass
         return the_input.new_completion(groups, n, '', quotify=True)
     return False
Beispiel #17
0
 def completion_groupremove(self, the_input):
     args = common.shell_split(the_input.text)
     n = the_input.get_argument_position()
     if n == 1:
         jids = sorted(jid for jid in roster.jids())
         return the_input.new_completion(jids, n, '', quotify=True)
     elif n == 2:
         contact = roster[args[1]]
         if contact is None:
             return False
         groups = sorted(contact.groups)
         try:
             groups.remove('none')
         except ValueError:
             pass
         return the_input.new_completion(groups, n, '', quotify=True)
     return False
Beispiel #18
0
 def completion_groupmove(self, the_input):
     args = common.shell_split(the_input.text)
     n = the_input.get_argument_position()
     if n == 1:
         jids = sorted(jid for jid in roster.jids())
         return the_input.new_completion(jids, n, '', quotify=True)
     elif n == 2:
         contact = roster[args[1]]
         if not contact:
             return False
         groups = list(contact.groups)
         if 'none' in groups:
             groups.remove('none')
         return the_input.new_completion(groups, n, '', quotify=True)
     elif n == 3:
         groups = sorted(group for group in roster.groups)
         return the_input.new_completion(groups, n, '', quotify=True)
     return False
Beispiel #19
0
 def completion_groupmove(self, the_input):
     args = common.shell_split(the_input.text)
     n = the_input.get_argument_position()
     if n == 1:
         jids = sorted(jid for jid in roster.jids())
         return the_input.new_completion(jids, n, '', quotify=True)
     elif n == 2:
         contact = roster[args[1]]
         if not contact:
             return False
         groups = list(contact.groups)
         if 'none' in groups:
             groups.remove('none')
         return the_input.new_completion(groups, n, '', quotify=True)
     elif n == 3:
         groups = sorted(group for group in roster.groups)
         return the_input.new_completion(groups, n, '', quotify=True)
     return False
Beispiel #20
0
    def command_deny(self, args):
        """
        /deny [jid]
        Denies a JID from our roster
        """
        if not args:
            item = self.roster_win.selected_row
            if isinstance(item, Contact):
                jid = item.bare_jid
            else:
                self.core.information('No subscription to deny')
                return
        else:
            jid = safeJID(args[0]).bare
            if not jid in [jid for jid in roster.jids()]:
                self.core.information('No subscription to deny')
                return

        contact = roster[jid]
        if contact:
            contact.unauthorize()
            self.core.information('Subscription to %s was revoked' % jid,
                                  'Roster')
Beispiel #21
0
    def command_deny(self, args):
        """
        /deny [jid]
        Denies a JID from our roster
        """
        if not args:
            item = self.roster_win.selected_row
            if isinstance(item, Contact):
                jid = item.bare_jid
            else:
                self.core.information('No subscription to deny')
                return
        else:
            jid = safeJID(args[0]).bare
            if not jid in [jid for jid in roster.jids()]:
                self.core.information('No subscription to deny')
                return

        contact = roster[jid]
        if contact:
            contact.unauthorize()
            self.core.information('Subscription to %s was revoked' % jid,
                                  'Roster')
Beispiel #22
0
 def completion_remove(self, the_input):
     """
     Completion for /remove
     """
     jids = [jid for jid in roster.jids()]
     return the_input.auto_completion(jids, '', quotify=False)
Beispiel #23
0
def completion_version(self, the_input):
    """Completion for /version"""
    comp = reduce(lambda x, y: x + [i.jid for i in y],
                  (roster[jid].resources
                   for jid in roster.jids() if len(roster[jid])), [])
    return the_input.new_completion(sorted(comp), 1, quotify=False)
Beispiel #24
0
def completion_version(self, the_input):
    """Completion for /version"""
    comp = reduce(
        lambda x, y: x + [i.jid for i in y], (roster[jid].resources for jid in roster.jids() if len(roster[jid])), []
    )
    return the_input.new_completion(sorted(comp), 1, quotify=False)
Beispiel #25
0
 def completion_remove(self, the_input):
     """
     Completion for /remove
     """
     jids = [jid for jid in roster.jids()]
     return the_input.auto_completion(jids, '', quotify=False)