示例#1
0
文件: chat.py 项目: Ninja-1/Circle2
    def stop(self):
        #self.change_activity('removing callbacks')
        self.channels.stop()
        
        self.node.remove_handler('chat message 2')
        #self.node.remove_handler('chat look')

        #thomasV: I guess the following should belong to name_server
        #self.app.name_server.remove_watch_callback(self)

        #self.change_activity('preparing config')
        config = { }
        for item in ['quiet','activity','offline_message_buffer']:
            config[item] = getattr(self,item)
        # Convert timestamps to standardized epoch.  The intent is to allow
        # sharing/copying a .circle directory between different operating
        # systems (in particular, between operating systems that have a
        # value of time.gmtime(0), i.e. different epochs).
        config['incoming_message_history'] \
          = map(lambda item: (item[0], host2standard_timestamp(item[1])),
                self.incoming_message_history)
        config['unread_message_list'] \
          = map(lambda item: (item[0], item[1], host2standard_timestamp(item[2])),
                self.unread_message_list)

        #self.change_activity('saving to disk')
        utility.set_config("chat",config)
示例#2
0
 def save(self):
     self.lock.acquire()
     try:
         list = [ ]
         for item in self.acquaintances.values():
             if item.remember:
                 list.append(item.to_map())
         utility.set_config('acquaintances', list)
     finally:
         self.lock.release()
示例#3
0
    def __init__(self, app, node, random_func):
        utility.Task_manager.__init__(self)

        self.app = app
        self.node = node

        self.key = utility.get_config("private_key",None)

        if self.key == None:
            random = random_func()
            self.key = crypto.RSA.deconstruct(crypto.RSA.generate(1024,random.randfunc))
            random.finish()
            utility.set_config("private_key",self.key)

        self.key  = crypto.RSA.construct(self.key)
        self.public_key = crypto.RSA.deconstruct(self.key.publickey())
        self.public_key_name = key_name(self.public_key)
        self.public_key_name_offline = hash.hash_of('identity-offline '+key_name(self.public_key))
        self.name   = None
        self.info   = { }
        self.status = { }    # eg chat status stored under 'chat' key

        # For searching for all people
        self.service_name = hash.hash_of("service identity")

        self.acquaintances = { }
        self.nicknames     = { }

        self.watchers      = [ ]                    #the people who are watching me
        
        self.watch_callbacks = [ ]

        self.start_time = time.time()

        self.get_info_func = lambda self=self: self.app.name_server.get_info()
        # - has to be a distinct object to allow unpublish
 
        self.aborted = 0
        self.disconnect_threads = 0

        # Proof of @R.I22: @E25
        self.check_invar()
示例#4
0
    def stop(self):

        self.change_activity('interrupting downloads')
        for downloader in self.downloaders:
            downloader.stop()
        self.change_activity('removing handlers')
        self.node.remove_handler('download chunk')
        self.node.remove_handler('files available')
        self.change_activity('')
        self.change_activity('saving hash cache')
        utility.set_config("hash_cache", self.cache)
        self.change_activity('')
        utility.Task_manager.stop(self)

        infos = []
        for entry in self.entries.values():
            if not entry.is_dir:
                infos.append(entry.info)
        self.change_activity('unpublishing %d file infos' % len(infos))
        self.node.unpublish_set(infos)
示例#5
0
文件: gossip.py 项目: Ninja-1/Circle2
 def save(self):
     gossip_list = [ ]
     for item in self.gossip:
         gossip_list.append(item.to_map())
     utility.set_config("gossip", gossip_list, 1)
示例#6
0
 def save(self):
     utility.set_config("channels", self.list);