Browse Source

create ice-like PlayerInfo objects for the dbus ifaces

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
33bcb3bce4
  1. 21
      pyweb/mumble/MumbleCtlDbus.py
  2. 19
      pyweb/mumble/MumbleCtlIce.py
  3. 13
      pyweb/mumble/mmobjects.py
  4. 4
      pyweb/mumble/models.py

21
pyweb/mumble/MumbleCtlDbus.py

@ -108,7 +108,26 @@ class MumbleCtlDbus_118(MumbleCtlBase):
return ret; return ret;
def getPlayers(self, srvid): def getPlayers(self, srvid):
return MumbleCtlDbus_118.convertDbusTypeToNative(self._getDbusServerObject(srvid).getPlayers())
players = MumbleCtlDbus_118.convertDbusTypeToNative(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]
);
return ret;
def getRegisteredPlayers(self, srvid, filter = ''): def getRegisteredPlayers(self, srvid, filter = ''):
return MumbleCtlDbus_118.convertDbusTypeToNative(self._getDbusServerObject(srvid).getRegisteredPlayers( filter ) ) return MumbleCtlDbus_118.convertDbusTypeToNative(self._getDbusServerObject(srvid).getRegisteredPlayers( filter ) )

19
pyweb/mumble/MumbleCtlIce.py

@ -113,14 +113,7 @@ class MumbleCtlIce_118(MumbleCtlBase):
@protectDjangoErrPage @protectDjangoErrPage
def getPlayers(self, srvid): 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
return self._getIceServerObject(srvid).getPlayers()
@protectDjangoErrPage @protectDjangoErrPage
def getDefaultConf(self): def getDefaultConf(self):
@ -308,15 +301,7 @@ class MumbleCtlIce_120(MumbleCtlIce_118):
@protectDjangoErrPage @protectDjangoErrPage
def getPlayers(self, srvid): def getPlayers(self, srvid):
serv = self._getIceServerObject(srvid);
users = serv.getUsers()
ret = []
for x in users:
user = users[x]
ret.append([user.session, user.mute, user.deaf, user.suppress, user.selfMute, user.selfDeaf, user.channel, user.userid, self.setUnicodeFlag(user.name), user.onlinesecs, user.bytespersec])
return ret
return self._getIceServerObject(srvid).getUsers();
@protectDjangoErrPage @protectDjangoErrPage
def registerPlayer(self, srvid, name, email, password): def registerPlayer(self, srvid, name, email, password):

13
pyweb/mumble/mmobjects.py

@ -194,7 +194,18 @@ class mmPlayer( object ):
# mumbleuser = models.MumbleUser(); # mumbleuser = models.MumbleUser();
def __init__( self, srvInstance, playerObj, playerChan ): def __init__( self, srvInstance, playerObj, playerChan ):
( self.userid, self.muted, self.deafened, self.suppressed, self.selfmuted, self.selfdeafened, chanID, self.dbaseid, self.name, onlinetime, self.bytesPerSec ) = playerObj;
self.userid = playerObj.session;
self.muted = playerObj.mute;
self.deafened = playerObj.deaf;
self.suppressed = playerObj.suppress;
self.selfmuted = playerObj.selfMute;
self.selfdeafened = playerObj.selfDeaf;
chanID = playerObj.channel;
self.dbaseid = playerObj.userid;
self.name = playerObj.name;
onlinetime = playerObj.onlinesecs;
self.bytesPerSec = playerObj.bytespersec;
self.onlinesince = datetime.datetime.fromtimestamp( float( time() - onlinetime ) ); self.onlinesince = datetime.datetime.fromtimestamp( float( time() - onlinetime ) );
self.channel = playerChan; self.channel = playerChan;
self.channel.players.append( self ); self.channel.players.append( self );

4
pyweb/mumble/models.py

@ -338,9 +338,9 @@ class Mumble( models.Model ):
self._channels[0].name = self.name; self._channels[0].name = self.name;
self.players = {}; self.players = {};
for thePlayer in self.ctl.getPlayers(self.srvid):
for thePlayer in self.ctl.getPlayers(self.srvid).values():
# Players - Fields: 0 = UserID, 6 = ChannelID # Players - Fields: 0 = UserID, 6 = ChannelID
self.players[ thePlayer[0] ] = mmPlayer( self, thePlayer, self._channels[ thePlayer[6] ] );
self.players[ thePlayer.session ] = mmPlayer( self, thePlayer, self._channels[ thePlayer.channel ] );
self._channels[0].sort(); self._channels[0].sort();

Loading…
Cancel
Save