Browse Source

move handling of the "playername"/"username" config field to the CTLs

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
fad11e6d4d
  1. 3
      pyweb/mumble/MumbleCtlDbus.py
  2. 34
      pyweb/mumble/MumbleCtlIce.py
  3. 9
      pyweb/mumble/models.py

3
pyweb/mumble/MumbleCtlDbus.py

@ -70,6 +70,9 @@ class MumbleCtlDbus_118(MumbleCtlBase):
return info; return info;
def setConf(self, srvid, key, value): def setConf(self, srvid, key, value):
if key == "username":
key = "playername";
self.meta.setConf(dbus.Int32( srvid ), key, value) self.meta.setConf(dbus.Int32( srvid ), key, value)
def getDefaultConf(self): def getDefaultConf(self):

34
pyweb/mumble/MumbleCtlIce.py

@ -170,7 +170,15 @@ class MumbleCtlIce_118(MumbleCtlBase):
@protectDjangoErrPage @protectDjangoErrPage
def getAllConf(self, srvid): def getAllConf(self, srvid):
return self.setUnicodeFlag(self._getIceServerObject(srvid).getAllConf())
conf = self.setUnicodeFlag(self._getIceServerObject(srvid).getAllConf())
info = {};
for key in conf:
if key == "playername":
info['username'] = conf[key];
else:
info[str(key)] = conf[key];
return info;
@protectDjangoErrPage @protectDjangoErrPage
def newServer(self): def newServer(self):
@ -200,6 +208,9 @@ class MumbleCtlIce_118(MumbleCtlBase):
@protectDjangoErrPage @protectDjangoErrPage
def setConf(self, srvid, key, value): def setConf(self, srvid, key, value):
if key == "username":
key = "playername";
self._getIceServerObject(srvid).setConf( key, value.encode( "UTF-8" ) ) self._getIceServerObject(srvid).setConf( key, value.encode( "UTF-8" ) )
@protectDjangoErrPage @protectDjangoErrPage
@ -385,6 +396,27 @@ class MumbleCtlIce_120(MumbleCtlIce_118):
}; };
return self._getIceServerObject( srvid ).updateRegistration( mumbleid, user ) return self._getIceServerObject( srvid ).updateRegistration( mumbleid, user )
@protectDjangoErrPage
def getAllConf(self, srvid):
conf = self.setUnicodeFlag(self._getIceServerObject(srvid).getAllConf())
info = {};
for key in conf:
if key == "playername" and conf[key]:
# Buggy database transition from 1.1.8 -> 1.2.0
# Store username as "username" field and set playername field to empty
info['username'] = conf[key];
self.setConf( srvid, "playername", "" );
self.setConf( srvid, "username", conf[key] );
else:
info[str(key)] = conf[key];
return info;
@protectDjangoErrPage
def setConf(self, srvid, key, value):
self._getIceServerObject(srvid).setConf( key, value.encode( "UTF-8" ) )
@protectDjangoErrPage @protectDjangoErrPage
def getACL(self, srvid, channelid): def getACL(self, srvid, channelid):
return self._getIceServerObject(srvid).getACL(channelid) return self._getIceServerObject(srvid).getACL(channelid)

9
pyweb/mumble/models.py

@ -134,12 +134,7 @@ class Mumble( models.Model ):
self.ctl.setConf( self.srvid, 'certificate', self.sslcrt ); self.ctl.setConf( self.srvid, 'certificate', self.sslcrt );
self.ctl.setConf( self.srvid, 'key', self.sslkey ); self.ctl.setConf( self.srvid, 'key', self.sslkey );
self.ctl.setConf( self.srvid, 'obfuscate', str(self.obfsc).lower() ); self.ctl.setConf( self.srvid, 'obfuscate', str(self.obfsc).lower() );
if self.ctl.getVersion()[:2] == ( 1, 2 ):
self.ctl.setConf( self.srvid, 'username', self.player );
else:
self.ctl.setConf( self.srvid, 'playername', self.player );
self.ctl.setConf( self.srvid, 'username', self.player );
self.ctl.setConf( self.srvid, 'channelname', self.channel ); self.ctl.setConf( self.srvid, 'channelname', self.channel );
self.ctl.setConf( self.srvid, 'defaultchannel', str(self.defchan) ); self.ctl.setConf( self.srvid, 'defaultchannel', str(self.defchan) );
@ -217,7 +212,7 @@ class Mumble( models.Model ):
self.obfsc = bool( find_in_dicts( 'obfuscate' ) ); self.obfsc = bool( find_in_dicts( 'obfuscate' ) );
pldefault = self._meta.get_field_by_name('player')[0].default; pldefault = self._meta.get_field_by_name('player')[0].default;
self.player = find_in_dicts( ( 'username', 'playername' ), pldefault );
self.player = find_in_dicts( 'username', pldefault );
chdefault = self._meta.get_field_by_name('channel')[0].default; chdefault = self._meta.get_field_by_name('channel')[0].default;
self.channel = find_in_dicts( 'channelname', chdefault ); self.channel = find_in_dicts( 'channelname', chdefault );

Loading…
Cancel
Save