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.

116 lines
3.4 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 (object):
  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 getRegistration(self, srvid, mumbleid):
  49. raise NotImplementedError( "mctl::setRegistration" );
  50. def setRegistration(self, srvid, mumbleid, name, email, password):
  51. raise NotImplementedError( "mctl::setRegistration" );
  52. def unregisterPlayer(self, srvid, mumbleid):
  53. raise NotImplementedError( "mctl::unregisterPlayer" );
  54. def getBootedServers(self):
  55. raise NotImplementedError( "mctl::getBootedServers" );
  56. def getAllServers(self):
  57. raise NotImplementedError( "mctl::getAllServers" );
  58. def getACL(self, srvid, channelid):
  59. raise NotImplementedError( "mctl::getACL" );
  60. def setACL(self, srvid, acl):
  61. raise NotImplementedError( "mctl::setACL" );
  62. def getTexture(self, srvid, mumbleid):
  63. raise NotImplementedError( "mctl::getTexture" );
  64. def setTexture(self, srvid, mumbleid, infile):
  65. raise NotImplementedError( "mctl::setTexture" );
  66. @staticmethod
  67. def newInstance( connstring ):
  68. # check cache
  69. if connstring in MumbleCtlBase.cache:
  70. return MumbleCtlBase.cache[connstring];
  71. # connstring defines whether to connect via ICE or DBus.
  72. # Dbus service names: some.words.divided.by.periods
  73. # ICE specs are WAY more complex, so if DBus doesn't match, use ICE.
  74. rd = re.compile( r'^(\w+\.)*\w+$' );
  75. if rd.match( connstring ):
  76. from MumbleCtlDbus import MumbleCtlDbus
  77. ctl = MumbleCtlDbus( connstring )
  78. else:
  79. from MumbleCtlIce import MumbleCtlIce
  80. ctl = MumbleCtlIce( connstring )
  81. MumbleCtlBase.cache[connstring] = ctl;
  82. return ctl;