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.

136 lines
4.1 KiB

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
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
  1. # -*- coding: utf-8 -*-
  2. """
  3. * Copyright © 2009, withgod <withgod@sourceforge.net>
  4. * 2009-2010, 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. """ This class defines the base interface that the Mumble model expects. """
  19. cache = {};
  20. def getAllConf(self, srvid):
  21. raise NotImplementedError( "mctl::getAllConf" );
  22. def getVersion( self ):
  23. raise NotImplementedError( "mctl::getVersion" );
  24. def getConf(self, srvid, key):
  25. raise NotImplementedError( "mctl::getConf" );
  26. def setConf(self, srvid, key, value):
  27. raise NotImplementedError( "mctl::setConf" );
  28. def getDefaultConf(self):
  29. raise NotImplementedError( "mctl::getDefaultConf" );
  30. def newServer(self):
  31. raise NotImplementedError( "mctl::newServer" );
  32. def setSuperUserPassword(self, srvid, value):
  33. raise NotImplementedError( "mctl::setSuperUserPassword" );
  34. def start(self, srvid):
  35. raise NotImplementedError( "mctl::start" );
  36. def stop(self, srvid):
  37. raise NotImplementedError( "mctl::stop" );
  38. def isBooted(self, srvid):
  39. raise NotImplementedError( "mctl::isBooted" );
  40. def deleteServer(self, srvid):
  41. raise NotImplementedError( "mctl::deleteServer" );
  42. def getPlayers(self, srvid):
  43. raise NotImplementedError( "mctl::getPlayers" );
  44. def getRegisteredPlayers(self, srvid, filter):
  45. raise NotImplementedError( "mctl::getRegisteredPlayers" );
  46. def getChannels(self, srvid):
  47. raise NotImplementedError( "mctl::getChannels" );
  48. def registerPlayer(self, srvid, name, email, password):
  49. raise NotImplementedError( "mctl::registerPlayer" );
  50. def getRegistration(self, srvid, mumbleid):
  51. raise NotImplementedError( "mctl::getRegistration" );
  52. def setRegistration(self, srvid, mumbleid, name, email, password):
  53. raise NotImplementedError( "mctl::setRegistration" );
  54. def unregisterPlayer(self, srvid, mumbleid):
  55. raise NotImplementedError( "mctl::unregisterPlayer" );
  56. def getBootedServers(self):
  57. raise NotImplementedError( "mctl::getBootedServers" );
  58. def getAllServers(self):
  59. raise NotImplementedError( "mctl::getAllServers" );
  60. def getACL(self, srvid, channelid):
  61. raise NotImplementedError( "mctl::getACL" );
  62. def setACL(self, srvid, channelid, acl, groups, inherit):
  63. raise NotImplementedError( "mctl::setACL" );
  64. def getTexture(self, srvid, mumbleid):
  65. raise NotImplementedError( "mctl::getTexture" );
  66. def setTexture(self, srvid, mumbleid, infile):
  67. raise NotImplementedError( "mctl::setTexture" );
  68. def verifyPassword( self, srvid, username, password ):
  69. raise NotImplementedError( "mctl::verifyPassword" );
  70. @staticmethod
  71. def newInstance( connstring, slicefile=None, icesecret=None ):
  72. """ Create a new CTL object for the given connstring.
  73. Optional parameters are the path to the slice file and the
  74. Ice secret necessary to authenticate to Murmur.
  75. The path can be omitted only if using DBus or running Murmur
  76. 1.2.3 or later, which exports a getSlice method to retrieve
  77. the Slice from.
  78. """
  79. # check cache
  80. if connstring in MumbleCtlBase.cache:
  81. return MumbleCtlBase.cache[connstring];
  82. # connstring defines whether to connect via ICE or DBus.
  83. # Dbus service names: some.words.divided.by.periods
  84. # ICE specs are WAY more complex, so if DBus doesn't match, use ICE.
  85. rd = re.compile( r'^(\w+\.)*\w+$' );
  86. if rd.match( connstring ):
  87. from MumbleCtlDbus import MumbleCtlDbus
  88. ctl = MumbleCtlDbus( connstring )
  89. else:
  90. from MumbleCtlIce import MumbleCtlIce
  91. ctl = MumbleCtlIce( connstring, slicefile, icesecret )
  92. MumbleCtlBase.cache[connstring] = ctl;
  93. return ctl;
  94. @staticmethod
  95. def clearCache():
  96. MumbleCtlBase.cache = {};