From 7c790ba929aadc1d1cac8e13e1fe3ab25cd20a1b Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Sat, 11 Jul 2009 12:52:50 +0200 Subject: [PATCH] changed *everything* just to handle the new user registration in Murmur 1.2.0. Hope it works. --- pyweb/mumble/MumbleCtlDbus.py | 6 ++++-- pyweb/mumble/MumbleCtlIce.py | 15 +++++++++++---- pyweb/mumble/mctl.py | 2 +- pyweb/mumble/models.py | 23 +++++++++++++---------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/pyweb/mumble/MumbleCtlDbus.py b/pyweb/mumble/MumbleCtlDbus.py index 6b70523..cfe60fc 100755 --- a/pyweb/mumble/MumbleCtlDbus.py +++ b/pyweb/mumble/MumbleCtlDbus.py @@ -70,8 +70,10 @@ class MumbleCtlDbus(MumbleCtlBase): def newServer(self): return self.meta.newServer() - def registerPlayer(self, srvid, name): - return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).registerPlayer(name)) + def registerPlayer(self, srvid, name, email, password): + mumbleid = MumbleCtlDbus.converDbusTypeToNative( self._getDbusServerObject(srvid).registerPlayer(name) ); + self.setRegistration( srvid, mumbleid, name, email, password ); + return mumbleid; def unregisterPlayer(self, srvid, mumbleid): self._getDbusServerObject(srvid).unregisterPlayer(dbus.Int32( mumbleid )) diff --git a/pyweb/mumble/MumbleCtlIce.py b/pyweb/mumble/MumbleCtlIce.py index c4584c5..6bace89 100755 --- a/pyweb/mumble/MumbleCtlIce.py +++ b/pyweb/mumble/MumbleCtlIce.py @@ -142,8 +142,10 @@ class MumbleCtlIce_118(MumbleCtlBase): 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 registerPlayer(self, srvid, name, email, password): + mumbleid = self._getIceServerObject(srvid).registerPlayer( name.encode( "UTF-8" ) ) + self.setRegistration( srvid, mumbleid, name, email, password ); + return mumbleid; def unregisterPlayer(self, srvid, mumbleid): self._getIceServerObject(srvid).unregisterPlayer(mumbleid) @@ -287,8 +289,13 @@ class MumbleCtlIce_120(MumbleCtlIce_118): return ret - def registerPlayer(self, srvid, name): - return self._getIceServerObject(srvid).registerUser( name.encode( "UTF-8" ) ) + def registerPlayer(self, srvid, name, email, password): + user = { + 'name': name.encode( "UTF-8" ), + 'email': email.encode( "UTF-8" ), + 'pw': password.encode( "UTF-8" ), + }; + return self._getIceServerObject(srvid).registerUser( user ); def unregisterPlayer(self, srvid, mumbleid): self._getIceServerObject(srvid).unregisterUser(mumbleid) diff --git a/pyweb/mumble/mctl.py b/pyweb/mumble/mctl.py index 3a50bee..fb29f58 100755 --- a/pyweb/mumble/mctl.py +++ b/pyweb/mumble/mctl.py @@ -59,7 +59,7 @@ class MumbleCtlBase (): def getChannels(self, srvid): raise NotImplementedError( "mctl::getChannels" ); - def registerPlayer(self, srvid, name): + def registerPlayer(self, srvid, name, email, password): raise NotImplementedError( "mctl::registerPlayer" ); def setRegistration(self, srvid, mumbleid, name, email, password): diff --git a/pyweb/mumble/models.py b/pyweb/mumble/models.py index 5903965..9a1d027 100755 --- a/pyweb/mumble/models.py +++ b/pyweb/mumble/models.py @@ -253,19 +253,22 @@ class MumbleUser( models.Model ): # Before the record set is saved, update Murmur via controller. ctl = self.server.ctl; + if self.owner: + email = self.owner.email; + else: + email = settings.DEFAULT_FROM_EMAIL; + if self.id is None: # This is a new user record, so Murmur doesn't know about it yet if len( ctl.getRegisteredPlayers( self.server.srvid, self.name ) ) > 0: raise ValueError( "Another player already registered that name." ); - self.mumbleid = ctl.registerPlayer( self.server.srvid, self.name ); + if not self.password: + raise ValueError( "Cannot register player without a password!" ); + + self.mumbleid = ctl.registerPlayer( self.server.srvid, self.name, email, self.password ); # Update user's registration - if self.password: - if self.owner: - email = self.owner.email - else: - email = settings.DEFAULT_FROM_EMAIL; - + elif self.password: ctl.setRegistration( self.server.srvid, self.mumbleid, @@ -273,9 +276,9 @@ class MumbleUser( models.Model ): email, self.password ); - - # Don't save the users' passwords, we don't need them anyway - self.password = ''; + + # Don't save the users' passwords, we don't need them anyway + self.password = ''; self.setAdmin( self.isAdmin );