Browse Source

standardize user information handling

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
6d32b13210
  1. 5
      muco.py
  2. 55
      pyweb/mumble/MumbleCtlDbus.py
  3. 54
      pyweb/mumble/MumbleCtlIce.py
  4. 4
      pyweb/mumble/mmobjects.py
  5. 21
      pyweb/mumble/models.py

5
muco.py

@ -156,8 +156,11 @@ class WndSettings( BaseWindow ):
key = self.win.getch();
if key == curses.KEY_UP and self.selIdx > 0:
if key == curses.KEY_UP:
if self.selIdx > 0:
self.selIdx -= 1;
else:
return;
elif key == curses.KEY_DOWN and self.selIdx < self.selMax:
self.selIdx += 1;

55
pyweb/mumble/MumbleCtlDbus.py

@ -87,7 +87,7 @@ class MumbleCtlDbus_118(MumbleCtlBase):
return self.meta.newServer()
def registerPlayer(self, srvid, name, email, password):
mumbleid = MumbleCtlDbus_118.convertDbusTypeToNative( self._getDbusServerObject(srvid).registerPlayer(name) );
mumbleid = int( self._getDbusServerObject(srvid).registerPlayer(name) );
self.setRegistration( srvid, mumbleid, name, email, password );
return mumbleid;
@ -95,44 +95,55 @@ class MumbleCtlDbus_118(MumbleCtlBase):
self._getDbusServerObject(srvid).unregisterPlayer(dbus.Int32( mumbleid ))
def getChannels(self, srvid):
chans = MumbleCtlDbus_118.convertDbusTypeToNative(self._getDbusServerObject(srvid).getChannels())
chans = self._getDbusServerObject(srvid).getChannels()
ret = {};
for channel in chans:
ret[ channel[0] ] = ObjectInfo(
id = channel[0],
name = channel[1],
parent = channel[2],
links = channel[3],
id = int(channel[0]),
name = str(channel[1]),
parent = int(channel[2]),
links = [ int(lnk) for lnk in channel[3] ],
);
return ret;
def getPlayers(self, srvid):
players = MumbleCtlDbus_118.convertDbusTypeToNative(self._getDbusServerObject(srvid).getPlayers());
players = self._getDbusServerObject(srvid).getPlayers();
ret = {};
for playerObj in players:
ret[ playerObj[0] ] = ObjectInfo(
session = playerObj[0],
mute = playerObj[1],
deaf = playerObj[2],
suppress = playerObj[3],
selfMute = playerObj[4],
selfDeaf = playerObj[5],
channel = playerObj[6],
userid = playerObj[7],
name = playerObj[8],
onlinesecs = playerObj[9],
bytespersec = playerObj[10]
ret[ int(playerObj[0]) ] = ObjectInfo(
session = int( playerObj[0] ),
mute = bool( playerObj[1] ),
deaf = bool( playerObj[2] ),
suppress = bool( playerObj[3] ),
selfMute = bool( playerObj[4] ),
selfDeaf = bool( playerObj[5] ),
channel = int( playerObj[6] ),
userid = int( playerObj[7] ),
name = str( playerObj[8] ),
onlinesecs = int( playerObj[9] ),
bytespersec = int( playerObj[10] )
);
return ret;
def getRegisteredPlayers(self, srvid, filter = ''):
return MumbleCtlDbus_118.convertDbusTypeToNative(self._getDbusServerObject(srvid).getRegisteredPlayers( filter ) )
users = self._getDbusServerObject(srvid).getRegisteredPlayers( filter );
ret = {};
for user in users:
ret[int(user[0])] = ObjectInfo(
userid = int( user[0] ),
name = unicode( user[1] ),
email = unicode( user[2] ),
pw = unicode( user[3] )
);
return ret
def getACL(self, srvid, channelid):
raw_acls, raw_groups, raw_inherit = self._getDbusServerObject(srvid).getACL(channelid)
@ -244,11 +255,11 @@ class MumbleCtlDbus_118(MumbleCtlBase):
return -2;
ok = MumbleCtlDbus_118.convertDbusTypeToNative(
self._getDbusServerObject(srvid).verifyPassword( dbus.Int32( player[0][0] ), password )
self._getDbusServerObject(srvid).verifyPassword( dbus.Int32( player[0].userid ), password )
);
if ok:
return player[0][0];
return player[0].userid;
else:
return -1;

54
pyweb/mumble/MumbleCtlIce.py

@ -24,6 +24,8 @@ from django.conf import settings
from mctl import MumbleCtlBase
from utils import ObjectInfo
import Ice
@ -113,10 +115,15 @@ class MumbleCtlIce_118(MumbleCtlBase):
@protectDjangoErrPage
def getRegisteredPlayers(self, srvid, filter = ''):
users = self._getIceServerObject(srvid).getRegisteredPlayers( filter.encode( "UTF-8" ) )
ret = []
ret = {};
for user in users:
ret.append([user.playerid, self.setUnicodeFlag(user.name), self.setUnicodeFlag(user.email), self.setUnicodeFlag(user.pw)])
ret[user.playerid] = ObjectInfo(
userid = int( user.playerid ),
name = unicode( user.name, "utf8" ),
email = unicode( user.email, "utf8" ),
pw = unicode( user.pw, "utf8" )
);
return ret
@ -126,7 +133,27 @@ class MumbleCtlIce_118(MumbleCtlBase):
@protectDjangoErrPage
def getPlayers(self, srvid):
return self._getIceServerObject(srvid).getPlayers()
users = self._getIceServerObject(srvid).getPlayers()
ret = {};
for useridx in users:
user = users[useridx];
ret[ user.session ] = ObjectInfo(
session = user.session,
userid = user.playerid,
mute = user.mute,
deaf = user.deaf,
suppress = user.suppressed,
selfMute = user.selfMute,
selfDeaf = user.selfDeaf,
channel = user.channel,
name = user.name,
onlinesecs = user.onlinesecs,
bytespersec = user.bytespersec
);
return ret;
@protectDjangoErrPage
def getDefaultConf(self):
@ -179,10 +206,12 @@ class MumbleCtlIce_118(MumbleCtlBase):
@protectDjangoErrPage
def getRegistration(self, srvid, mumbleid):
user = self._getIceServerObject(srvid).getRegistration(mumbleid)
return {
'name': user.name,
'email': user.email,
};
return ObjectInfo(
userid = mumbleid,
name = user.name,
email = user.email,
pw = '',
);
@protectDjangoErrPage
def setRegistration(self, srvid, mumbleid, name, email, password):
@ -292,10 +321,15 @@ class MumbleCtlIce_120(MumbleCtlIce_118):
@protectDjangoErrPage
def getRegisteredPlayers(self, srvid, filter = ''):
users = self._getIceServerObject( srvid ).getRegisteredUsers( filter.encode( "UTF-8" ) )
ret = []
ret = {};
for id in users:
ret.append( [ id, self.setUnicodeFlag( users[id] ) ] );
ret[id] = ObjectInfo(
userid = id,
name = unicode( users[id], "utf8" ),
email = '',
pw = ''
);
return ret
@ -332,7 +366,7 @@ class MumbleCtlIce_120(MumbleCtlIce_118):
user['comment'] = reg[UserInfo.UserComment];
if UserInfo.UserHash in reg:
user['hash'] = reg[UserInfo.UserHash];
return user;
return ObjectInfo( **user );
@protectDjangoErrPage
def setRegistration(self, srvid, mumbleid, name, email, password):

4
pyweb/mumble/mmobjects.py

@ -24,6 +24,7 @@ from django.utils.http import urlquote
from django.conf import settings
def cmp_names( a, b ):
""" Compare two objects by their name property. """
return cmp( a.name, b.name );
@ -222,7 +223,7 @@ class mmPlayer( object ):
class mmACL:
class mmACL( object ):
"""Represents an ACL for a certain channel."""
def __init__( self, channel, aclObj ):
@ -271,6 +272,7 @@ class mmACL:
group.remove.append( userid );
def save( self ):
""" Send this ACL to Murmur. """
return self.channel.server.ctl.setACL(
self.channel.server.srvid,
self.channel.chanid,

21
pyweb/mumble/models.py

@ -237,22 +237,24 @@ class Mumble( models.Model ):
players = self.ctl.getRegisteredPlayers(self.srvid);
for playerdata in players:
if playerdata[0] == 0: # Skip SuperUsers
for idx in players:
playerdata = players[idx];
if playerdata.userid == 0: # Skip SuperUsers
continue;
if verbose > 1:
print "Checking Player with id %d and name '%s'." % ( int(playerdata[0]), playerdata[1] );
print "Checking Player with id %d and name '%s'." % ( playerdata.userid, playerdata.name );
try:
playerinstance = MumbleUser.objects.get( server=self, mumbleid=playerdata[0] );
playerinstance = MumbleUser.objects.get( server=self, mumbleid=playerdata.userid );
except MumbleUser.DoesNotExist:
if verbose:
print 'Found new Player "%s".' % playerdata[1];
print 'Found new Player "%s".' % playerdata.name;
playerinstance = MumbleUser(
mumbleid = playerdata[0],
name = playerdata[1],
mumbleid = playerdata.userid,
name = playerdata.name,
password = '',
server = self,
owner = None
@ -262,7 +264,7 @@ class Mumble( models.Model ):
if verbose > 1:
print "This player is already listed in the database.";
playerinstance.name = playerdata[1];
playerinstance.name = playerdata.name;
playerinstance.isAdmin = playerinstance.getAdmin();
playerinstance.save( dontConfigureMurmur=True );
@ -290,7 +292,7 @@ class Mumble( models.Model ):
# Channel list
def getChannels( self ):
"""Query the channels from Murmur and create a tree structure.
""" Query the channels from Murmur and create a tree structure.
Again, this will only be done for the first call to this function. Subsequent
calls will simply return the list created last time.
@ -507,6 +509,7 @@ class MumbleUser( models.Model ):
texture = property( getTexture, setTexture, doc="Get the texture as a PIL Image or read from a file (pass the path)." );
def hasTexture( self ):
""" Check if this user has a texture set. """
try:
self.getTexture();
except ValueError:

Loading…
Cancel
Save