示例#1
0
 def __init__(self, logging):
     self.logger = newLogger("Core Messages")
     self._lock = loggingMutex("messages", logging=logging)
     self._db, plugin_type = get_db_connection(self.logger)
     
     if self._db is None:
         self._length = 0
         self._latest = None
         return
     
     if plugin_type != "SQLite Connection":
         self.logger.warning("Your standard connection is not of type SQLite." + \
             "Loading messages from another type is experimental.")
     
     if not self._db.existsTable("CORE_MESSAGE_VERSION"):
         self._db.execute("CREATE TABLE CORE_MESSAGE_VERSION(VERSION INTEGER)")
         self._db.execute("INSERT INTO CORE_MESSAGE_VERSION(VERSION) VALUES(?)", self._DB_VERSION_CURRENT)
                     
     if not self._db.existsTable("CORE_MESSAGES"):
         self._db.execute("CREATE TABLE CORE_MESSAGES(SENDER TEXT, TIME REAL, MESSAGE TEXT)")
         self._db.execute("CREATE INDEX CORE_MESSAGE_TIME_INDEX on CORE_MESSAGES(TIME ASC)")
         self._length = 0
         self._latest = None
         self.importOld(get_settings().get_legacy_messages_file())
     else:
         self._latest = self._getLatest()
         self._length = self._getNumMessages()    
示例#2
0
 def __init__(self):
     super(lunch_server, self).__init__()
     self.controller = None
     self.initialized = False
     self._disable_broadcast = False
     self.running = False
     self._peer_nr = 0
     self._peers = None
     self.plugin_manager = None
     self._message_queues = {} # queues for messages from new peers
     self._last_messages = {} # last messages by peer ID, to avoid duplicates
     self._send_logger = newLogger("Core Send")
     self._recv_logger = newLogger("Core Recv")
     
     self.message_queues_lock = loggingMutex("message_queues", logging=get_settings().get_verbose())
     self.cached_messages_lock = loggingMutex("cached_messages", logging=get_settings().get_verbose())
     
     self.exitCode = 0  
 def __init__(self, jsonString):
     # {plugin name : {action name : {settings}}}
     self.logger = newLogger("Privacy")
     try:
         self._settings = json.loads(jsonString)
     except ValueError:
         self.logger.exception("Error reading privacy settings from JSON.")
         self._settings = {}
     
     self._modifications = {}
     self._lock = loggingMutex("Privacy Settings", logging=get_settings().get_verbose())
示例#4
0
 def activate(self):
     """
     Call the parent class's activation method
     """
     IPlugin.activate(self)
     
     self.logger = newLogger(self.plugin_name)
     self._initOptions()
     self._readOptionsFromFile()
     if len(self._supported_dbms)>0:
         get_notification_center().connectDBSettingChanged(self.connect_to_db)
         self.connect_to_db()
     return
示例#5
0
    def __init__(self):
        """after initializing all variables, the peer information form the lust run is read from a file"""
        self.logger = newLogger("Peers")
        self._potentialPeers = set()  # set containing data from lunch_peers.cfg
        self._memberIDs = set()  # of PeerIDs members: peers that sent their info, are active and belong to my group
        self._IP_seen = {}  # last seen timestamps by IP
        self._peer_info = {}  # information of every peer by IP
        self._idToIp = {}  # mapping from ID to a set of IPs

        self._groups = set()  # seen group names

        self._lock = loggingMutex("peers", logging=get_settings().get_verbose())

        if get_settings().get_plugins_enabled():
            self._peerNames = PeerNames()
        else:
            self._peerNames = None
示例#6
0
 def __init__(self):
     self.logger = newLogger("Peer Names")
     self._db, plugin_type = get_db_connection(self.logger)
     self._peerNameCache = {} # peer ID -> (peer name, custom name)
     
     if self._db is None:
         return
     
     if plugin_type != "SQLite Connection":
         self.logger.warning("Your standard connection is not of type SQLite." + \
             "Loading peer names from another type is experimental.")
     
     if not self._db.existsTable("CORE_PEER_NAME_VERSION"):
         self._db.execute("CREATE TABLE CORE_PEER_NAME_VERSION(VERSION INTEGER)")
         self._db.execute("INSERT INTO CORE_PEER_NAME_VERSION(VERSION) VALUES(?)", self._DB_VERSION_CURRENT)
                     
     if not self._db.existsTable("CORE_PEER_NAMES"):
         self._db.execute("CREATE TABLE CORE_PEER_NAMES(PEER_ID TEXT PRIMARY KEY NOT NULL, PEER_NAME TEXT NOT NULL, CUSTOM_NAME TEXT)")
         if self._db.existsTable("CORE_MESSAGE_PEER_NAMES"):
             # copy from message peer names
             self._db.execute("INSERT INTO CORE_PEER_NAMES SELECT PEER_ID, PEER_NAME, NULL FROM CORE_MESSAGE_PEER_NAMES")
             self._db.execute("DROP TABLE CORE_MESSAGE_PEER_NAMES")