diff --git a/pyweb/mumble/MumbleCtlDbus.py b/pyweb/mumble/MumbleCtlDbus.py index 371a434..aad2903 100755 --- a/pyweb/mumble/MumbleCtlDbus.py +++ b/pyweb/mumble/MumbleCtlDbus.py @@ -46,19 +46,19 @@ class MumbleCtlDbus(MumbleCtlBase): def getAllConf(self, srvid): return MumbleCtlDbus.converDbusTypeToNative(self.meta.getAllConf(dbus.Int32(srvid))) - + def setConf(self, srvid, key, value): self.meta.setConf(dbus.Int32( srvid ), key, value) - + def getDefaultConf(self): return MumbleCtlDbus.converDbusTypeToNative(self.meta.getDefaultConf()) def start( self, srvid ): self.meta.start( srvid ); - + def stop( self, srvid ): self.meta.stop( srvid ); - + def isBooted( self, srvid ): return bool( self.meta.isBooted( srvid ) ); @@ -66,46 +66,46 @@ class MumbleCtlDbus(MumbleCtlBase): srvid = dbus.Int32( srvid ) if self.meta.isBooted( srvid ): self.meta.stop( srvid ) - + self.meta.deleteServer( srvid ) - + def newServer(self): return self.meta.newServer() - + def registerPlayer(self, srvid, name): return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).registerPlayer(name)) - + def unregisterPlayer(self, srvid, mumbleid): self._getDbusServerObject(srvid).unregisterPlayer(dbus.Int32( mumbleid )) - + def getChannels(self, srvid): return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).getChannels()) - + def getPlayers(self, srvid): return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).getPlayers()) - + def getRegisteredPlayers(self, srvid, filter = ''): return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).getRegisteredPlayers( filter ) ) - - def getACL(self, srvid, identifier): - return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).getACL(identifier)) - + + def getACL(self, srvid, channelid): + return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).getACL(channelid)) + def setACL(self, srvid, acl): self._getDbusServerObject(srvid).setACL(*acl.pack()) - + def getBootedServers(self): return MumbleCtlDbus.converDbusTypeToNative(self.meta.getBootedServers()) - + def getAllServers(self): return MumbleCtlDbus.converDbusTypeToNative(self.meta.getAllServers()) - + def setSuperUserPassword(self, srvid, value): self.meta.setSuperUserPassword(dbus.Int32(srvid), value) - + def setRegistration(self, srvid, mumbleid, name, email, password): return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).setRegistration(dbus.Int32(mumbleid), name, email, password)) #return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).setRegistration(dbus.Int32(mumbleid), dbus.String(name), dbus.String(email), dbus.String(password))) - + def getTexture(self, srvid, mumbleid): texture = self._getDbusServerObject(srvid).getTexture(dbus.Int32(mumbleid)); @@ -128,7 +128,7 @@ class MumbleCtlDbus(MumbleCtlBase): # return an 600x60 RGBA image object created from the data return Image.fromstring( "RGBA", ( 600, 60 ), imgdata); - + def setTexture(self, srvid, mumbleid, infile): # open image, convert to RGBA, and resize to 600x60 img = Image.open( infile ).convert( "RGBA" ).transform( ( 600, 60 ), Image.EXTENT, ( 0, 0, 600, 60 ) ); @@ -145,13 +145,13 @@ class MumbleCtlDbus(MumbleCtlBase): texture = pack( ">L", len(bgrastring) ) + compressed; # finally call murmur and set the texture self._getDbusServerObject(srvid).setTexture(dbus.Int32( mumbleid ), texture) - + @staticmethod def converDbusTypeToNative(data): #i know dbus.* type is extends python native type. #but dbus.* type is not native type. it's not good transparent for using Ice/Dbus. ret = None - + if isinstance(data, tuple) or type(data) is data.__class__ is dbus.Array or data.__class__ is dbus.Struct: ret = [] for x in data: diff --git a/pyweb/mumble/MumbleCtlIce.py b/pyweb/mumble/MumbleCtlIce.py index bd86e01..2c01c51 100755 --- a/pyweb/mumble/MumbleCtlIce.py +++ b/pyweb/mumble/MumbleCtlIce.py @@ -65,10 +65,10 @@ class MumbleCtlIce_118(MumbleCtlBase): def __init__( self, connstring, meta ): self.proxy = connstring; self.meta = meta; - + def _getIceServerObject(self, srvid): return self.meta.getServer(srvid); - + def getBootedServers(self): ret = [] for x in self.meta.getBootedServers(): @@ -83,90 +83,71 @@ class MumbleCtlIce_118(MumbleCtlBase): for x in self.meta.getAllServers(): ret.append(x.id()) return ret - + def getRegisteredPlayers(self, srvid, filter = ''): users = self._getIceServerObject(srvid).getRegisteredPlayers( filter.encode( "UTF-8" ) ) ret = [] - + for user in users: ret.append([user.playerid, self.setUnicodeFlag(user.name), self.setUnicodeFlag(user.email), self.setUnicodeFlag(user.pw)]) - + return ret - + def getChannels(self, srvid): chans = self._getIceServerObject(srvid).getChannels() ret = [] - + for x in chans: chan = chans[x] ret.append([chan.id, self.setUnicodeFlag(chan.name), chan.parent, chan.links]) - + return ret - + def getPlayers(self, srvid): users = self._getIceServerObject(srvid).getPlayers() ret = [] - + for x in users: user = users[x] ret.append([user.session, user.mute, user.deaf, user.suppressed, user.selfMute, user.selfDeaf, user.channel, user.playerid, self.setUnicodeFlag(user.name), user.onlinesecs, user.bytespersec]) - - return ret - - def getACL(self, srvid, identifier): - import Murmur - acls = self._getIceServerObject(srvid).getACL(identifier) - ret = [] - for x in acls: - if isinstance(x, list): - tmp = [] - for y in x: - if y.__class__ is Murmur.ACL: - tmp.append([y.applyHere, y.applySubs, y.inherited, y.playerid, self.setUnicodeFlag(y.group), y.allow, y.deny]) - elif y.__class__ is Murmur.Group: - tmp.append([self.setUnicodeFlag(y.name), y.inherited, y.inherit, y.inheritable, y.add, y.remove, y.members]) - - ret.append(tmp) - else: - ret.append(x) return ret - + def getDefaultConf(self): return self.setUnicodeFlag(self.meta.getDefaultConf()) - + def getAllConf(self, srvid): return self.setUnicodeFlag(self._getIceServerObject(srvid).getAllConf()) - + def newServer(self): return self.meta.newServer().id() - + def isBooted( self, srvid ): return bool( self._getIceServerObject(srvid).isRunning() ); def start( self, srvid ): self._getIceServerObject(srvid).start(); - + def stop( self, srvid ): self._getIceServerObject(srvid).stop(); - + def deleteServer( self, srvid ): if self._getIceServerObject(srvid).isRunning(): self._getIceServerObject(srvid).stop() self._getIceServerObject(srvid).delete() - + def setSuperUserPassword(self, srvid, value): self._getIceServerObject(srvid).setSuperuserPassword( value.encode( "UTF-8" ) ) - + def setConf(self, srvid, key, value): self._getIceServerObject(srvid).setConf( key, value.encode( "UTF-8" ) ) - + def registerPlayer(self, srvid, name): return self._getIceServerObject(srvid).registerPlayer( name.encode( "UTF-8" ) ) - + def unregisterPlayer(self, srvid, mumbleid): self._getIceServerObject(srvid).unregisterPlayer(mumbleid) - + def setRegistration(self, srvid, mumbleid, name, email, password): user = self._getIceServerObject(srvid).getRegistration(mumbleid) user.name = name.encode( "UTF-8" ) @@ -174,7 +155,26 @@ class MumbleCtlIce_118(MumbleCtlBase): user.pw = password.encode( "UTF-8" ) # update*r*egistration r is lowercase... return self._getIceServerObject(srvid).updateregistration(user) - + + def getACL(self, srvid, channelid): + import Murmur + acls = self._getIceServerObject(srvid).getACL(channelid) + ret = [] + for x in acls: + if isinstance(x, list): + tmp = [] + for y in x: + if y.__class__ is Murmur.ACL: + tmp.append([y.applyHere, y.applySubs, y.inherited, y.playerid, self.setUnicodeFlag(y.group), y.allow, y.deny]) + elif y.__class__ is Murmur.Group: + tmp.append([self.setUnicodeFlag(y.name), y.inherited, y.inherit, y.inheritable, y.add, y.remove, y.members]) + + ret.append(tmp) + else: + ret.append(x) + + return ret + def setACL(self, srvid, acl): import Murmur @@ -250,7 +250,7 @@ class MumbleCtlIce_118(MumbleCtlBase): ret[MumbleCtlIce_118.setUnicodeFlag(key)] = MumbleCtlIce_118.setUnicodeFlag(data[key]) else: ret = unicode(data, 'utf-8') - + return ret @@ -260,22 +260,22 @@ class MumbleCtlIce_120(MumbleCtlIce_118): def getRegisteredPlayers(self, srvid, filter = ''): users = self._getIceServerObject( srvid ).getRegisteredUsers( filter.encode( "UTF-8" ) ) ret = [] - + for user in users: ret.append([user.playerid, self.setUnicodeFlag(user.name), self.setUnicodeFlag(user.email), self.setUnicodeFlag(user.pw)]) - + return ret - + def getChannels(self, srvid): chans = self._getIceServerObject(srvid).getChannels() ret = [] - + for x in chans: chan = chans[x] ret.append([chan.id, self.setUnicodeFlag(chan.name), chan.parent, chan.links, chan.description]) - + return ret - + def getPlayers(self, srvid): serv = self._getIceServerObject(srvid); users = serv.getUsers() @@ -284,15 +284,15 @@ class MumbleCtlIce_120(MumbleCtlIce_118): for x in users: user = users[x] ret.append([user.session, user.mute, user.deaf, user.suppressed, user.selfMute, user.selfDeaf, user.channel, user.playerid, self.setUnicodeFlag(user.name), user.onlinesecs, user.bytespersec]) - + return ret - + def registerPlayer(self, srvid, name): return self._getIceServerObject(srvid).registerUser( name.encode( "UTF-8" ) ) - + def unregisterPlayer(self, srvid, mumbleid): self._getIceServerObject(srvid).unregisterUser(mumbleid) - + def setRegistration(self, srvid, mumbleid, name, email, password): user = self._getIceServerObject( srvid ).getRegistration( mumbleid ) user['name'] = name.encode( "UTF-8" ) @@ -300,9 +300,9 @@ class MumbleCtlIce_120(MumbleCtlIce_118): user['pw'] = password.encode( "UTF-8" ) return self._getIceServerObject( srvid ).updateRegistration( mumbleid, user ) - def getACL(self, srvid, identifier): + def getACL(self, srvid, channelid): import Murmur - acls = self._getIceServerObject(srvid).getACL(identifier) + acls = self._getIceServerObject(srvid).getACL(channelid) ret = [] for x in acls: if isinstance(x, list): @@ -348,3 +348,5 @@ class MumbleCtlIce_120(MumbleCtlIce_118): newgroups.append( new_group ); self._getIceServerObject(srvid).setACL( acl.channelId, newacls, newgroups, acl.inherit ); + + diff --git a/pyweb/mumble/mctl.py b/pyweb/mumble/mctl.py index 607e78d..0d2fe1c 100755 --- a/pyweb/mumble/mctl.py +++ b/pyweb/mumble/mctl.py @@ -78,7 +78,7 @@ class MumbleCtlBase (): def getAllServers(self): raise NotImplementedError( "mctl::getAllServers" ); - def getACL(self, srvid, identifier): + def getACL(self, srvid, channelid): raise NotImplementedError( "mctl::getACL" ); def setACL(self, srvid, acl): diff --git a/pyweb/mumble/models.py b/pyweb/mumble/models.py index bfbb52f..dae123b 100755 --- a/pyweb/mumble/models.py +++ b/pyweb/mumble/models.py @@ -323,7 +323,8 @@ class MumbleUser( models.Model ): kwargs['instance'].unregister(); def unregister( self ): - # Unregister this player in Murmur via dbus. + if self.getAdmin(): + self.setAdmin( False ); self.server.ctl.unregisterPlayer(self.server.srvid, self.mumbleid)