Example #1
0
def do_add(self, param):
    """Deprecated. Useful for text mode only. Use /remember in the gui mode"""
    try:
        value = int(param[0])

    except ValueError:
        raise error.Error(_("/add requires a number (ie a result from /find)."))

    if value > len(self.identity_list):
        raise error.Error(_("The list of identities isn't that long."))
    if value < 1:
        raise error.Error(_("/add requires a positive number."))
    value = self.identity_list[value-1].item

    def add_thread(self,value=value):
        result, thread = self.app.name_server.make_acquaintance(value, None)
        yield 'wait',thread
        if result:
            acq=result[0]
            acq.watch = 1
            acq.remember = 1
            name = acq.nickname
            self.show(_('%s has been added to your contact list.\n')%name)
            acq.start_watching(self.app.node)
            
    utility.start_thread(add_thread(self))
Example #2
0
def do_recall(self, params_dummy):
    
    def recall_thread(self,recall_list,field):
        if recall_list == [ ]:
            field.show( _('No message to recall.\n'), ['grey'])
        else:
            str = ''
            for item in recall_list:
                field.show(str+('Recalling message to %s...\n') % item[0],['grey'])
                pipe = self.node.retrieve(item[1],settings.cache_redundancy)
                n    = 0
                while not pipe.finished():
                    for pair in pipe.read_all():
                        if pair[1] == item[2]:
                            try:
                                ticket = self.node.call(pair[0],('data cache remove',item[3]))
                                yield 'call',(self.node,ticket)
                                result = node.get_result(ticket)
                                n = n + 1
                            except error.Error:
                                pass
                    yield 'sleep',0.25

                if n == settings.cache_redundancy:
                    str = str + _('Recalled all %d copies of message to %s.\n') % (n,item[0])
                elif n == 0:
                    str = str + _('Could not recall message to %s.\n') % item[0]
                else:
                    str = str + _('Recalled %d copies of message to %s.\n') % (n,item[0])            
            field.show( str, ['grey'])
            
        field.close()

    utility.start_thread(recall_thread(self, self.recall_list, self.get_field()))
Example #3
0
def do_join(chat_obj, params):

    def join_thread(chat_obj,params):

        if not params:
            if not chat_obj.channel:
                chat_obj.show(_('Use /join <nickname> to talk to someone.\n'))
            chat_obj.set_channel([ ])
            return

        param = params[0]
        if param[0] in '+-':
            prefix = param[0]
            param = param[1:]
        else:
            prefix = ''

        new_list = utility.split_list(param)
        old_list = chat_obj.channel[:]

        if prefix == '+':
            for item in old_list:
                if item not in new_list:
                    new_list.append(item)

        elif prefix == '-':
            for item in new_list:
                if item in old_list:
                    old_list.remove(item)
                else:
                    chat_obj.show(_('Not joined to %s\n')%item)    
            new_list = old_list

        for item in new_list:
            if item[0]!='#':
                result, thread = chat_obj.app.name_server.check_acquaintance(chat_obj.identity_list,item)
                yield 'wait',thread
                if not result:
                    chat_obj.show( 'No %s in your aquaintances list.\n'% item,'grey')
                    new_list.remove(item)

        chat_obj.set_channel(new_list)
        if new_list:
            chat_obj.show(_('Joined %s\n') % string.join(chat_obj.channel,',') )
        else:
            chat_obj.show(_('Joined nobody\n') )

    utility.start_thread(join_thread(chat_obj,params))
Example #4
0
def do_remember(self,param):
    """Replacement of /add. Takes a nickname as argument"""

    def remember_thread(self,param):
        nickname = param[0]
        result, thread = self.app.name_server.check_acquaintance(self.identity_list,nickname)
        yield 'wait',thread
        if result:
            acq=result[0]
            acq.remember = 1
            self.show( _('%s will be remembered.\n')%acq.nickname)
            name = acq.nickname
        else:
            self.show( 'I know nothing about %s. Try \'/find %s\' before.\n'% (nickname,nickname),'grey')
            
    utility.start_thread( remember_thread(self,param))
Example #5
0
    def show_interior(self, root):

        def show_interior_thread(root, self):

            size=0
            stats=''
            root.still_searching=1
            sleep_time= 0.01
            list = []
            while root.list:
                root.list.remove(root.list[0])
            while root.still_searching:

                yield 'sleep',sleep_time
                sleep_time=sleep_time*1.25
                root.update(self.app)
                children = root.get_children()

                for leaf in children:
                    if leaf not in list:
                        if leaf.item['type']=='directory':
                            leaf.expanded=0
                        elif leaf.item['type']== 'file':
                            size=size+leaf.item['length']

                        root.list.append(leaf)
                        number=len(root.list)
                        self.show("%d "%number + leaf.get_text()) 
                        list.append(leaf)

                root.update(self.app)

            root.pipe.stop()
            
            stats='    '*root.depth()+'%d %s'%(len(root.list),root.what)
            if root.what=='files':
                stats=stats +', '+utility.human_size(size)
            if not root.list:
                stats='    '*root.depth()+root.empty_text
            if len(root.list)==1:
                stats='    '*root.depth()+root.single_text                
            self.show(stats+'.')


        utility.start_thread(show_interior_thread(root,self))
Example #6
0
def do_ls(self,list):
    utility.start_thread(ls_thread(self,list))
Example #7
0
                    else:
                        str = _(' is quiet: %s') % result[1]

                #str = str + _(' (on %s)') % utility.hostname_of_ip(address[0])
            else:
                str = _(' is offline')
            field.show(nick,'people')
            field.name = acq.name
            field2=self.get_field_after(field)
            field2.show(str+'\n','grey')
        except error.Error,err:
            print err.message
        field.close()

    if param:
        utility.start_thread(look_thread(self, param[0], self.get_field()))
    else:
        values = self.app.name_server.acquaintances.values()
        for item in values:
            if item.watch:
                utility.start_thread(look_thread(self, item.nickname, self.get_field('person')))


def do_who(self, params):
    
    # todo:
    # if I subscribe to a channel, I should be warned when people join/leave

    if params:

        channel= params[0]
Example #8
0
                        str = ' '+result[1]
                else:
                    if result[1] == '':
                        str = _(' is quiet')
                    else:
                        str = _(' is quiet: %s') % result[1]

                #str = str + _(' (on %s)') % utility.hostname_of_ip(address[0])
            else:
                str = _(' is offline')
            self.show(nick+str)
        except error.Error,err:
            print err.message

    if param:
        utility.start_thread(look_thread(self, param[0]))
    else:
        values = self.app.name_server.acquaintances.values()
        for item in values:
            if item.watch:
                utility.start_thread(look_thread(self, item.nickname))


def do_who(self, params):
    
    # todo:
    # if I subscribe to a channel, I should be warned when people join/leave

    if params:

        channel= params[0]