Added missing file

parent 2be17ba8
...@@ -29,7 +29,7 @@ import sys ...@@ -29,7 +29,7 @@ import sys
from socket import SOL_SOCKET, SO_BROADCAST, AF_INET, SOCK_DGRAM, socket from socket import SOL_SOCKET, SO_BROADCAST, AF_INET, SOCK_DGRAM, socket
import IN import IN
import struct import struct
from nexlibs.dmcrypt import AES256 from nexlibs.nexcrypt import AES256
from nexlibs import nexcrypt as dmcrypt from nexlibs import nexcrypt as dmcrypt
import logging import logging
from dmlib import constants as C from dmlib import constants as C
......
###########################################################################
# Copyright (c) 2011-2014 Unixmedia S.r.l. <info@unixmedia.it>
# Copyright (c) 2011-2014 Franco (nextime) Lanza <franco@unixmedia.it>
#
# Domotika System Controller Daemon "domotikad" [http://trac.unixmedia.it]
#
# This file is part of domotikad.
#
# domotikad is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from nexlibs.singleton import Singleton
from twisted.internet import reactor
EXPIRETIME=300
class MessengerLinksSingleton(Singleton):
links = {}
expires = {}
def __init__(self, *args, **kwargs):
Singleton.__init__( self )
def del_expire(self, linkid):
if linkid in self.expires.keys():
try:
self.expires[linkid].cancel()
except:
pass
del self.expires[linkid]
def add_expire(self, linkid):
self.del_expire(linkid)
self.expires[linkid] = reactor.callLater(EXPIRETIME, self.del_link, linkid)
def add_link(self, linkid, usr):
self.links[linkid] = usr;
self.add_expire(linkid)
def del_link(self, linkid):
if linkid in self.links.keys():
del self.links[linkid]
def get_link(self, linkid):
if linkid in self.links.keys():
return self.links[linkid]
return False
def linkid_exists(self, linkid):
if linkid in self.links.keys():
return True
return False
def MessengerLinkRegistry():
return MessengerLinksSingleton.getInstance()
class MessengerPSIDSingleton(Singleton):
links = {}
def __init__(self, *args, **kwargs):
Singleton.__init__( self )
def add_link(self, linkid, usr):
self.links[linkid] = usr;
def del_link(self, linkid):
if linkid in self.links.keys():
del self.links[linkid]
def get_link(self, linkid):
if linkid in self.links.keys():
return self.links[linkid]
return False
def linkid_exists(self, linkid):
if linkid in self.links.keys():
return True
return False
def MessengerPSIDRegistry():
return MessengerPSIDSingleton.getInstance()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment