Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

666 lines
22 KiB

16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
  1. # -*- coding: utf-8 -*-
  2. """
  3. * Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
  4. *
  5. * Mumble-Django is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This package is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. """
  15. import socket, Ice
  16. from django.utils.translation import ugettext_noop, ugettext_lazy as _
  17. from django.contrib.auth.models import User
  18. from django.db import models
  19. from django.db.models import signals
  20. from django.conf import settings
  21. from mumble.mmobjects import mmChannel, mmPlayer
  22. from mumble.mctl import MumbleCtlBase
  23. def mk_config_property( field, doc="", get_coerce=None, get_none=None, set_coerce=unicode, set_none='' ):
  24. """ Create a property for the given config field. """
  25. def get_field( self ):
  26. if self.id is not None:
  27. val = self.getConf( field );
  28. if val is None or val == '':
  29. return get_none
  30. if callable(get_coerce):
  31. return get_coerce( val )
  32. return val
  33. return None
  34. def set_field( self, value ):
  35. if value is None:
  36. self.setConf( field, set_none )
  37. elif callable(set_coerce):
  38. self.setConf( field, set_coerce(value) )
  39. else:
  40. self.setConf( field, value )
  41. return property( get_field, set_field, doc=doc )
  42. def mk_config_bool_property( field, doc="" ):
  43. return mk_config_property( field, doc=doc,
  44. get_coerce = lambda value: value == "true",
  45. set_coerce = lambda value: str(value).lower()
  46. );
  47. class MumbleServer( models.Model ):
  48. """ Represents a Murmur server installation. """
  49. dbus = models.CharField( _('DBus or ICE base'), max_length=200, unique=True, default=settings.DEFAULT_CONN, help_text=_(
  50. "Examples: 'net.sourceforge.mumble.murmur' for DBus or 'Meta:tcp -h 127.0.0.1 -p 6502' for Ice.") );
  51. secret = models.CharField( _('Ice Secret'), max_length=200, blank=True );
  52. class Meta:
  53. verbose_name = _('Mumble Server');
  54. verbose_name_plural = _('Mumble Servers');
  55. def __init__( self, *args, **kwargs ):
  56. models.Model.__init__( self, *args, **kwargs );
  57. self._ctl = None;
  58. self._conf = None;
  59. def __unicode__( self ):
  60. return self.dbus;
  61. # Ctl instantiation
  62. def getCtl( self ):
  63. """ Instantiate and return a MumbleCtl object for this server.
  64. Only one instance will be created, and reused on subsequent calls.
  65. """
  66. if not self._ctl:
  67. self._ctl = MumbleCtlBase.newInstance( self.dbus, settings.SLICE, self.secret );
  68. return self._ctl;
  69. ctl = property( getCtl, doc="Get a Control object for this server. The ctl is cached for later reuse." );
  70. def getDefaultConf( self, field=None ):
  71. """ Get a field from the default conf dictionary, or None if the field isn't set. """
  72. if self._conf is None:
  73. self._conf = self.ctl.getDefaultConf()
  74. if field is None:
  75. return self._conf
  76. if field in self._conf:
  77. return self._conf[field]
  78. return None
  79. def isOnline( self ):
  80. """ Return true if this server process is running. """
  81. try:
  82. self.ctl
  83. except Ice.ConnectionRefusedException:
  84. return False;
  85. else:
  86. return True;
  87. online = property( isOnline )
  88. defaultconf = property( getDefaultConf, doc="The default config dictionary." )
  89. class Mumble( models.Model ):
  90. """ Represents a Murmur server instance.
  91. All configurable settings are represented by a field in this model. To change the
  92. settings, just update the appropriate field and call the save() method.
  93. To set up a new server instance, instanciate this Model. The first field you should
  94. define is the "dbus" field, which tells the connector subsystem how to connect to
  95. the Murmurd master process. Set this to the appropriate DBus service name or the
  96. Ice proxy string.
  97. When an instance of this model is deleted, the according server instance will be
  98. deleted as well.
  99. """
  100. server = models.ForeignKey( MumbleServer );
  101. name = models.CharField( _('Server Name'), max_length=200 );
  102. srvid = models.IntegerField( _('Server ID'), editable=False );
  103. addr = models.CharField( _('Server Address'), max_length=200, blank=True, help_text=_(
  104. "Hostname or IP address to bind to. You should use a hostname here, because it will appear on the "
  105. "global server list.") );
  106. port = models.IntegerField( _('Server Port'), blank=True, null=True, help_text=_(
  107. "Port number to bind to. Leave empty to auto assign one.") );
  108. display = models.CharField( _('Server Display Address'), max_length=200, blank=True, help_text=_(
  109. "This field is only relevant if you are located behind a NAT, and names the Hostname or IP address "
  110. "to use in the Channel Viewer and for the global server list registration. If not given, the addr "
  111. "and port fields are used. If display and bind ports are equal, you can omit it here.") );
  112. supw = property( lambda self: '',
  113. lambda self, value: self.ctl.setSuperUserPassword( self.srvid, value ),
  114. doc=_('Superuser Password')
  115. )
  116. url = mk_config_property( "registerurl", ugettext_noop("Website URL") )
  117. motd = mk_config_property( "welcometext", ugettext_noop("Welcome Message") )
  118. passwd = mk_config_property( "password", ugettext_noop("Server Password") )
  119. users = mk_config_property( "users", ugettext_noop("Max. Users"), get_coerce=int )
  120. bwidth = mk_config_property( "bandwidth", ugettext_noop("Bandwidth [Bps]"), get_coerce=int )
  121. sslcrt = mk_config_property( "certificate", ugettext_noop("SSL Certificate") )
  122. sslkey = mk_config_property( "key", ugettext_noop("SSL Key") )
  123. player = mk_config_property( "username", ugettext_noop("Player name regex") )
  124. channel = mk_config_property( "channelname", ugettext_noop("Channel name regex") )
  125. defchan = mk_config_property( "defaultchannel", ugettext_noop("Default channel"), get_coerce=int )
  126. timeout = mk_config_property( "timeout", ugettext_noop("Timeout"), get_coerce=int )
  127. obfsc = mk_config_bool_property( "obfuscate", ugettext_noop("IP Obfuscation") )
  128. certreq = mk_config_bool_property( "certrequired", ugettext_noop("Require Certificate") )
  129. textlen = mk_config_bool_property( "textmessagelength", ugettext_noop("Maximum length of text messages") )
  130. html = mk_config_bool_property( "allowhtml", ugettext_noop("Allow HTML to be used in messages") )
  131. bonjour = mk_config_bool_property( "bonjour", ugettext_noop("Publish this server via Bonjour") )
  132. autoboot= mk_config_bool_property( "boot", ugettext_noop("Boot Server when Murmur starts") )
  133. def getBooted( self ):
  134. if self.id is not None:
  135. try:
  136. return self.ctl.isBooted( self.srvid );
  137. except Ice.ConnectionRefusedException:
  138. return False;
  139. else:
  140. return False
  141. def setBooted( self, value ):
  142. if value != self.getBooted():
  143. if value:
  144. self.ctl.start( self.srvid );
  145. else:
  146. self.ctl.stop( self.srvid );
  147. booted = property( getBooted, setBooted, doc=ugettext_noop("Boot Server") )
  148. class Meta:
  149. unique_together = ( ( 'server', 'srvid' ), );
  150. verbose_name = _('Server instance');
  151. verbose_name_plural = _('Server instances');
  152. def __unicode__( self ):
  153. if not self.id:
  154. return u'Murmur "%s" (NOT YET CREATED)' % self.name;
  155. return u'Murmur "%s" (%d)' % ( self.name, self.srvid );
  156. def save( self, dontConfigureMurmur=False ):
  157. """ Save the options configured in this model instance not only to Django's database,
  158. but to Murmur as well.
  159. """
  160. if dontConfigureMurmur:
  161. # skip murmur configuration, e.g. because we're inserting models for existing servers.
  162. return models.Model.save( self );
  163. # check if this server already exists, if not call newServer and set my srvid first
  164. if self.id is None:
  165. self.srvid = self.ctl.newServer();
  166. self.ctl.setConf( self.srvid, 'registername', self.name );
  167. if self.addr and self.addr != '0.0.0.0':
  168. self.ctl.setConf( self.srvid, 'host', socket.gethostbyname(self.addr) );
  169. else:
  170. self.ctl.setConf( self.srvid, 'host', '' );
  171. if self.port and self.port != settings.MUMBLE_DEFAULT_PORT + self.srvid - 1:
  172. self.ctl.setConf( self.srvid, 'port', str(self.port) );
  173. else:
  174. self.ctl.setConf( self.srvid, 'port', '' );
  175. if self.netloc:
  176. self.ctl.setConf( self.srvid, 'registerhostname', self.netloc );
  177. else:
  178. self.ctl.setConf( self.srvid, 'registerhostname', '' );
  179. # Now allow django to save the record set
  180. return models.Model.save( self );
  181. def __init__( self, *args, **kwargs ):
  182. models.Model.__init__( self, *args, **kwargs );
  183. self._channels = None;
  184. self._rootchan = None;
  185. users_regged = property( lambda self: self.mumbleuser_set.count(), doc="Number of registered users." );
  186. users_online = property( lambda self: len(self.ctl.getPlayers(self.srvid)), doc="Number of online users." );
  187. channel_cnt = property( lambda self: len(self.ctl.getChannels(self.srvid)), doc="Number of channels." );
  188. is_public = property( lambda self: self.passwd == '',
  189. doc="False if a password is needed to join this server." );
  190. is_server = True;
  191. is_channel = False;
  192. is_player = False;
  193. ctl = property( lambda self: self.server.ctl );
  194. def getConf( self, field ):
  195. return self.ctl.getConf( self.srvid, field )
  196. def setConf( self, field, value ):
  197. return self.ctl.setConf( self.srvid, field, value )
  198. def configureFromMurmur( self ):
  199. conf = self.ctl.getAllConf( self.srvid );
  200. if "registername" not in conf or not conf["registername"]:
  201. self.name = "noname";
  202. else:
  203. self.name = conf["registername"];
  204. if "registerhostname" in conf and conf["registerhostname"]:
  205. if ':' in conf["registerhostname"]:
  206. regname, regport = conf["registerhostname"].split(':')
  207. regport = int(regport)
  208. else:
  209. regname = conf["registerhostname"]
  210. regport = None
  211. else:
  212. regname = None
  213. regport = None
  214. if "host" in conf and conf["host"]:
  215. addr = conf["host"]
  216. else:
  217. addr = None
  218. if "port" in conf and conf["port"]:
  219. self.port = int(conf["port"])
  220. else:
  221. self.port = None
  222. if regname and addr:
  223. if regport == self.port:
  224. if socket.gethostbyname(regname) == socket.gethostbyname(addr):
  225. self.display = ''
  226. self.addr = regname
  227. else:
  228. self.display = regname
  229. self.addr = addr
  230. else:
  231. self.display = conf["registerhostname"]
  232. self.addr = addr
  233. elif regname and not addr:
  234. self.display = regname
  235. self.addr = ''
  236. elif addr and not regname:
  237. self.display = ''
  238. self.addr = addr
  239. else:
  240. self.display = ''
  241. self.addr = ''
  242. self.save( dontConfigureMurmur=True );
  243. def readUsersFromMurmur( self, verbose=0 ):
  244. if not self.booted:
  245. raise SystemError( "This murmur instance is not currently running, can't sync." );
  246. players = self.ctl.getRegisteredPlayers(self.srvid);
  247. known_ids = [rec["mumbleid"]
  248. for rec in MumbleUser.objects.filter( server=self ).values( "mumbleid" )
  249. ]
  250. for idx in players:
  251. playerdata = players[idx];
  252. if playerdata.userid == 0: # Skip SuperUsers
  253. continue;
  254. if verbose > 1:
  255. print "Checking Player with id %d." % playerdata.userid;
  256. if playerdata.userid not in known_ids:
  257. if verbose:
  258. print 'Found new Player "%s".' % playerdata.name;
  259. playerinstance = MumbleUser(
  260. mumbleid = playerdata.userid,
  261. name = playerdata.name,
  262. password = '',
  263. server = self,
  264. owner = None
  265. );
  266. else:
  267. if verbose > 1:
  268. print "Player '%s' is already listed in the database." % playerdata.name;
  269. playerinstance = MumbleUser.objects.get( server=self, mumbleid=playerdata.userid );
  270. playerinstance.name = playerdata.name;
  271. playerinstance.save( dontConfigureMurmur=True );
  272. def isUserAdmin( self, user ):
  273. """ Determine if the given user is an admin on this server. """
  274. if user.is_authenticated():
  275. if user.is_superuser:
  276. return True;
  277. try:
  278. return self.mumbleuser_set.get( owner=user ).getAdmin();
  279. except MumbleUser.DoesNotExist:
  280. return False;
  281. return False;
  282. # Deletion handler
  283. def deleteServer( self ):
  284. """ Delete this server instance from Murmur. """
  285. self.ctl.deleteServer(self.srvid)
  286. @staticmethod
  287. def pre_delete_listener( **kwargs ):
  288. kwargs['instance'].deleteServer();
  289. # Channel list
  290. def getChannels( self ):
  291. """ Query the channels from Murmur and create a tree structure.
  292. Again, this will only be done for the first call to this function. Subsequent
  293. calls will simply return the list created last time.
  294. """
  295. if self._channels is None:
  296. self._channels = {};
  297. chanlist = self.ctl.getChannels(self.srvid).values();
  298. links = {};
  299. # sometimes, ICE seems to return the Channel list in a weird order.
  300. # itercount prevents infinite loops.
  301. itercount = 0;
  302. maxiter = len(chanlist) * 3;
  303. while len(chanlist) and itercount < maxiter:
  304. itercount += 1;
  305. for theChan in chanlist:
  306. # Channels - Fields: 0 = ID, 1 = Name, 2 = Parent-ID, 3 = Links
  307. if( theChan.parent == -1 ):
  308. # No parent
  309. self._channels[theChan.id] = mmChannel( self, theChan );
  310. elif theChan.parent in self.channels:
  311. # parent already known
  312. self._channels[theChan.id] = mmChannel( self, theChan, self.channels[theChan.parent] );
  313. else:
  314. continue;
  315. chanlist.remove( theChan );
  316. self._channels[theChan.id].serverId = self.id;
  317. # process links - if the linked channels are known, link; else save their ids to link later
  318. for linked in theChan.links:
  319. if linked in self._channels:
  320. self._channels[theChan.id].linked.append( self._channels[linked] );
  321. else:
  322. if linked not in links:
  323. links[linked] = list();
  324. links[linked].append( self._channels[theChan.id] );
  325. # check if earlier round trips saved channel ids to be linked to the current channel
  326. if theChan.id in links:
  327. for targetChan in links[theChan.id]:
  328. targetChan.linked.append( self._channels[theChan.id] );
  329. self._channels[0].name = self.name;
  330. self.players = {};
  331. for thePlayer in self.ctl.getPlayers(self.srvid).values():
  332. # Players - Fields: 0 = UserID, 6 = ChannelID
  333. self.players[ thePlayer.session ] = mmPlayer( self, thePlayer, self._channels[ thePlayer.channel ] );
  334. self._channels[0].sort();
  335. return self._channels;
  336. channels = property( getChannels, doc="A convenience wrapper for getChannels()." );
  337. rootchan = property( lambda self: self.channels[0], doc="A convenience wrapper for getChannels()[0]." );
  338. def getNetloc( self ):
  339. """ Return the address from the Display field (if any), or the server address.
  340. Users from outside a NAT will need to use the Display address to connect
  341. to this server instance.
  342. """
  343. if self.display:
  344. if ":" in self.display:
  345. return self.display;
  346. else:
  347. daddr = self.display;
  348. else:
  349. daddr = self.addr;
  350. if self.port and self.port != settings.MUMBLE_DEFAULT_PORT:
  351. return "%s:%d" % (daddr, self.port);
  352. else:
  353. return daddr;
  354. netloc = property( getNetloc );
  355. def getURL( self, forUser = None ):
  356. """ Create an URL of the form mumble://username@host:port/ for this server. """
  357. if not self.netloc:
  358. return None
  359. from urlparse import urlunsplit
  360. versionstr = "version=%d.%d.%d" % tuple(self.version[:3]);
  361. if forUser is not None:
  362. netloc = "%s@%s" % ( forUser.name, self.netloc );
  363. return urlunsplit(( "mumble", netloc, "", versionstr, "" ))
  364. else:
  365. return urlunsplit(( "mumble", self.netloc, "", versionstr, "" ))
  366. connecturl = property( getURL, doc=getURL.__doc__ );
  367. version = property( lambda self: self.ctl.getVersion(), doc="The version of Murmur." );
  368. def asDict( self ):
  369. return { 'name': self.name,
  370. 'id': self.id,
  371. 'root': self.rootchan.asDict()
  372. };
  373. # "server" field protection
  374. def __setattr__( self, name, value ):
  375. if name == 'server':
  376. if self.id is not None and self.server != value:
  377. raise AttributeError( _( "This field must not be updated once the record has been saved." ) );
  378. models.Model.__setattr__( self, name, value );
  379. def kickUser( self, sessionid, reason="" ):
  380. return self.ctl.kickUser( self.srvid, sessionid, reason );
  381. def banUser( self, sessionid, reason="" ):
  382. return self.ctl.addBanForSession( self.srvid, sessionid, reason=reason );
  383. def mk_registration_property( field, doc="" ):
  384. """ Create a property for the given registration field. """
  385. def get_field( self ):
  386. if "comment" in self.registration:
  387. return self.registration["comment"];
  388. else:
  389. return None;
  390. return property( get_field, doc=doc )
  391. class MumbleUser( models.Model ):
  392. """ Represents a User account in Murmur.
  393. To change an account, simply set the according field in this model and call the save()
  394. method to update the account in Murmur and in Django's database. Note that, once saved
  395. for the first time, the server field must not be changed. Attempting to do this will
  396. result in an AttributeError. To move an account to a new server, recreate it on the
  397. new server and delete the old model.
  398. When you delete an instance of this model, the according user account will be deleted
  399. in Murmur as well, after revoking the user's admin privileges.
  400. """
  401. mumbleid = models.IntegerField( _('Mumble player_id'), editable = False, default = -1 );
  402. name = models.CharField( _('User name and Login'), max_length = 200 );
  403. password = models.CharField( _('Login password'), max_length = 200, blank=True );
  404. server = models.ForeignKey( Mumble, verbose_name=_('Server instance'), related_name="mumbleuser_set" );
  405. owner = models.ForeignKey( User, verbose_name=_('Account owner'), related_name="mumbleuser_set", null=True, blank=True );
  406. comment = mk_registration_property( "comment", doc=ugettext_noop("The user's comment.") );
  407. hash = mk_registration_property( "hash", doc=ugettext_noop("The user's hash.") );
  408. class Meta:
  409. unique_together = ( ( 'server', 'owner' ), ( 'server', 'mumbleid' ) );
  410. verbose_name = _( 'User account' );
  411. verbose_name_plural = _( 'User accounts' );
  412. is_server = False;
  413. is_channel = False;
  414. is_player = True;
  415. def __unicode__( self ):
  416. return _("Mumble user %(mu)s on %(srv)s owned by Django user %(du)s") % {
  417. 'mu': self.name,
  418. 'srv': self.server,
  419. 'du': self.owner
  420. };
  421. def save( self, dontConfigureMurmur=False ):
  422. """ Save the settings in this model to Murmur. """
  423. if dontConfigureMurmur:
  424. # skip murmur configuration, e.g. because we're inserting models for existing players.
  425. return models.Model.save( self );
  426. # Before the record set is saved, update Murmur via controller.
  427. ctl = self.server.ctl;
  428. if self.owner:
  429. email = self.owner.email;
  430. else:
  431. email = settings.DEFAULT_FROM_EMAIL;
  432. if self.id is None:
  433. # This is a new user record, so Murmur doesn't know about it yet
  434. if len( ctl.getRegisteredPlayers( self.server.srvid, self.name ) ) > 0:
  435. raise ValueError( _( "Another player already registered that name." ) );
  436. if not self.password:
  437. raise ValueError( _( "Cannot register player without a password!" ) );
  438. self.mumbleid = ctl.registerPlayer( self.server.srvid, self.name, email, self.password );
  439. # Update user's registration
  440. elif self.password:
  441. ctl.setRegistration(
  442. self.server.srvid,
  443. self.mumbleid,
  444. self.name,
  445. email,
  446. self.password
  447. );
  448. # Don't save the users' passwords, we don't need them anyway
  449. self.password = '';
  450. # Now allow django to save the record set
  451. return models.Model.save( self );
  452. def __init__( self, *args, **kwargs ):
  453. models.Model.__init__( self, *args, **kwargs );
  454. self._registration = None;
  455. # Admin handlers
  456. def getAdmin( self ):
  457. """ Get ACL of root Channel, get the admin group and see if this user is in it. """
  458. if self.mumbleid == -1:
  459. return False;
  460. else:
  461. return self.server.rootchan.acl.group_has_member( "admin", self.mumbleid );
  462. def setAdmin( self, value ):
  463. """ Set or revoke this user's membership in the admin group on the root channel. """
  464. if self.mumbleid == -1:
  465. return False;
  466. if value:
  467. self.server.rootchan.acl.group_add_member( "admin", self.mumbleid );
  468. else:
  469. self.server.rootchan.acl.group_remove_member( "admin", self.mumbleid );
  470. self.server.rootchan.acl.save();
  471. return value;
  472. aclAdmin = property( getAdmin, setAdmin, doc=ugettext_noop('Admin on root channel') );
  473. # Registration fetching
  474. def getRegistration( self ):
  475. """ Retrieve a user's registration from Murmur as a dict. """
  476. if not self._registration:
  477. self._registration = self.server.ctl.getRegistration( self.server.srvid, self.mumbleid );
  478. return self._registration;
  479. registration = property( getRegistration, doc=getRegistration.__doc__ );
  480. # Texture handlers
  481. def getTexture( self ):
  482. """ Get the user texture as a PIL Image. """
  483. return self.server.ctl.getTexture(self.server.srvid, self.mumbleid);
  484. def setTexture( self, image ):
  485. """ Install the given image as the user's texture. """
  486. self.server.ctl.setTexture(self.server.srvid, self.mumbleid, image)
  487. texture = property( getTexture, setTexture,
  488. doc="Get the texture as a PIL Image or set the Image as the texture."
  489. );
  490. def hasTexture( self ):
  491. """ Check if this user has a texture set. """
  492. try:
  493. self.getTexture();
  494. except ValueError:
  495. return False;
  496. else:
  497. return True;
  498. def getTextureUrl( self ):
  499. """ Get a URL under which the texture can be retrieved. """
  500. from views import showTexture
  501. from django.core.urlresolvers import reverse
  502. return reverse( showTexture, kwargs={ 'server': self.server.id, 'userid': self.id } );
  503. textureUrl = property( getTextureUrl );
  504. # Deletion handler
  505. @staticmethod
  506. def pre_delete_listener( **kwargs ):
  507. kwargs['instance'].unregister();
  508. def unregister( self ):
  509. """ Delete this user account from Murmur. """
  510. if self.getAdmin():
  511. self.setAdmin( False );
  512. self.server.ctl.unregisterPlayer(self.server.srvid, self.mumbleid)
  513. # "server" field protection
  514. def __setattr__( self, name, value ):
  515. if name == 'server':
  516. if self.id is not None and self.server != value:
  517. raise AttributeError( _( "This field must not be updated once the record has been saved." ) );
  518. models.Model.__setattr__( self, name, value );
  519. signals.pre_delete.connect( Mumble.pre_delete_listener, sender=Mumble );
  520. signals.pre_delete.connect( MumbleUser.pre_delete_listener, sender=MumbleUser );