Exemple #1
0
    def run(self):
        log.msg("Init hermes logic unit instance")
        self.tagParser = TagParser()

        # preparing database
        self.db = sqlite3.connect(os.path.join(config()["spool"]["path"], config()["spool"]["db"]))
        self.db.isolation_level = None
        self.db.row_factory = sqlite3.Row

        c = self.db.cursor()
        c.execute(
            """CREATE TABLE IF NOT EXISTS contacts
                (id INTEGER PRIMARY KEY AUTOINCREMENT,
                 type INTEGER,
                 address TEXT,
                 privilege INTEGER,
                 subscription TEXT)"""
        )
        c.execute(
            """CREATE UNIQUE INDEX IF NOT EXISTS uniq_contact_address
                ON contacts(type, address)"""
        )

        self.contacts = ContactsManager()
        self.xmpp = xmpp.XmppMessenger()

        demon.init()
        super(HermesCore, self).run()
Exemple #2
0
    def run(self):
        log.msg("Init hermes logic unit instance")
        self.tagParser = TagParser()

        # preparing database
        self.db = sqlite3.connect(
            os.path.join(config()['spool']['path'],
                         config()['spool']['db']))
        self.db.isolation_level = None
        self.db.row_factory = sqlite3.Row

        c = self.db.cursor()
        c.execute('''CREATE TABLE IF NOT EXISTS contacts
                (id INTEGER PRIMARY KEY AUTOINCREMENT,
                 type INTEGER,
                 address TEXT,
                 privilege INTEGER,
                 subscription TEXT)''')
        c.execute('''CREATE UNIQUE INDEX IF NOT EXISTS uniq_contact_address
                ON contacts(type, address)''')

        self.contacts = ContactsManager()
        self.xmpp = xmpp.XmppMessenger()

        demon.init()
        super(HermesCore, self).run()
Exemple #3
0
    def __init__(self):
        super(XmppMessenger, self).__init__()
        self.me = jid.JID(config()['xmpp']['me'])
        self.xmlstream = False
        self.kaTimer = None
        self.kaResponseTimer = None
        self.lastSendTime = datetime.datetime.today() - datetime.timedelta(days=1)

        f = client.XMPPClientFactory(self.me, config()['xmpp']['password'])
        f.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT, self.connected)
        f.addBootstrap(xmlstream.STREAM_END_EVENT, self.disconnected)
        f.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, self.authenticated)
        f.addBootstrap(xmlstream.INIT_FAILED_EVENT, self.init_failed)
        self.connector = XMPPClientConnector(reactor, self.me.host, f)
        self.connect()
Exemple #4
0
    def __init__(self):
        super(XmppMessenger, self).__init__()
        self.me = jid.JID(config()['xmpp']['me'])
        self.xmlstream = False
        self.kaTimer = None
        self.kaResponseTimer = None
        self.lastSendTime = datetime.datetime.today() - datetime.timedelta(
            days=1)

        f = client.XMPPClientFactory(self.me, config()['xmpp']['password'])
        f.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT, self.connected)
        f.addBootstrap(xmlstream.STREAM_END_EVENT, self.disconnected)
        f.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, self.authenticated)
        f.addBootstrap(xmlstream.INIT_FAILED_EVENT, self.init_failed)
        self.connector = XMPPClientConnector(reactor, self.me.host, f)
        self.connect()
Exemple #5
0
    def pickServer(self):
        host, port = SRVConnector.pickServer(self)

        if not self.servers and not self.orderedServers:
            # no SRV record, fall back..
            port = int(config()['xmpp']['port'])

        return host, port
Exemple #6
0
 def auth(self, user, password):
     logins = config()["logins"]["login"]
     authorized = filter(lambda l: l.user == user and l.password == password, logins)
     if len(authorized):
         self.senderName = " or ".join([i.name for i in authorized])
         self.senderLogin = user
         return True
     return False
Exemple #7
0
    def pickServer(self):
        host, port = SRVConnector.pickServer(self)

        if not self.servers and not self.orderedServers:
            # no SRV record, fall back..
            port = int(config()['xmpp']['port'])

        return host, port
Exemple #8
0
 def auth(self, user, password):
     logins = config()['logins']['login']
     authorized = filter(
         lambda l: l.user == user and l.password == password, logins)
     if len(authorized):
         self.senderName = " or ".join([i.name for i in authorized])
         self.senderLogin = user
         return True
     return False
Exemple #9
0
 def __init__(self,**kwargs):
     self.lexer = lex.lex(module=self, **kwargs)
     self.parser = yacc.yacc(module=self,
                             outputdir=config()['spool']['path'],
                             debugfile=os.path.join(config()['spool']['path'], "tag_parser_debug.log"))
Exemple #10
0
 def servicesDict(self):
     ret = {}
     logins = config()["logins"]["login"]
     for l in logins:
         ret[l.user] = l.name
     return ret
Exemple #11
0
 def servicesDict(self):
     ret = {}
     logins = config()['logins']['login']
     for l in logins:
         ret[l.user] = l.name
     return ret