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.

113 lines
3.3 KiB

  1. # -*- coding: utf-8 -*-
  2. """
  3. * Copyright (C) 2009, withgod <withgod@sourceforge.net>
  4. * Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
  5. *
  6. * Mumble-Django is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This package is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. """
  16. import re
  17. class MumbleCtlBase ():
  18. cache = {};
  19. ''' abstract Ctrol Object '''
  20. def getAllConf(self, srvid):
  21. raise NotImplementedError( "mctl::getAllConf" );
  22. def getVersion( self ):
  23. raise NotImplementedError( "mctl::getVersion" );
  24. def setConf(self, srvid, key, value):
  25. raise NotImplementedError( "mctl::setConf" );
  26. def getDefaultConf(self):
  27. raise NotImplementedError( "mctl::getDefaultConf" );
  28. def newServer(self):
  29. raise NotImplementedError( "mctl::newServer" );
  30. def setSuperUserPassword(self, srvid, value):
  31. raise NotImplementedError( "mctl::setSuperUserPassword" );
  32. def start(self, srvid):
  33. raise NotImplementedError( "mctl::start" );
  34. def stop(self, srvid):
  35. raise NotImplementedError( "mctl::stop" );
  36. def isBooted(self, srvid):
  37. raise NotImplementedError( "mctl::isBooted" );
  38. def deleteServer(self, srvid):
  39. raise NotImplementedError( "mctl::deleteServer" );
  40. def getPlayers(self, srvid):
  41. raise NotImplementedError( "mctl::getPlayers" );
  42. def getRegisteredPlayers(self, srvid, filter):
  43. raise NotImplementedError( "mctl::getRegisteredPlayers" );
  44. def getChannels(self, srvid):
  45. raise NotImplementedError( "mctl::getChannels" );
  46. def registerPlayer(self, srvid, name, email, password):
  47. raise NotImplementedError( "mctl::registerPlayer" );
  48. def setRegistration(self, srvid, mumbleid, name, email, password):
  49. raise NotImplementedError( "mctl::setRegistration" );
  50. def unregisterPlayer(self, srvid, mumbleid):
  51. raise NotImplementedError( "mctl::unregisterPlayer" );
  52. def getBootedServers(self):
  53. raise NotImplementedError( "mctl::getBootedServers" );
  54. def getAllServers(self):
  55. raise NotImplementedError( "mctl::getAllServers" );
  56. def getACL(self, srvid, channelid):
  57. raise NotImplementedError( "mctl::getACL" );
  58. def setACL(self, srvid, acl):
  59. raise NotImplementedError( "mctl::setACL" );
  60. def getTexture(self, srvid, mumbleid):
  61. raise NotImplementedError( "mctl::getTexture" );
  62. def setTexture(self, srvid, mumbleid, infile):
  63. raise NotImplementedError( "mctl::setTexture" );
  64. @staticmethod
  65. def newInstance( connstring ):
  66. # check cache
  67. if connstring in MumbleCtlBase.cache:
  68. return MumbleCtlBase.cache[connstring];
  69. # connstring defines whether to connect via ICE or DBus.
  70. # Dbus service names: some.words.divided.by.periods
  71. # ICE specs are WAY more complex, so if DBus doesn't match, use ICE.
  72. rd = re.compile( r'^(\w+\.)*\w+$' );
  73. if rd.match( connstring ):
  74. from MumbleCtlDbus import MumbleCtlDbus
  75. ctl = MumbleCtlDbus( connstring )
  76. else:
  77. from MumbleCtlIce import MumbleCtlIce
  78. ctl = MumbleCtlIce( connstring )
  79. MumbleCtlBase.cache[connstring] = ctl;
  80. return ctl;