Browse Source

implement sending messages to users and channels

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
e9a4c1d454
  1. 8
      pyweb/mumble/MumbleCtlDbus.py
  2. 8
      pyweb/mumble/MumbleCtlIce.py
  3. 42
      pyweb/mumble/media/js/channelviewerplugins.js
  4. 6
      pyweb/mumble/models.py
  5. 14
      pyweb/mumble/views.py

8
pyweb/mumble/MumbleCtlDbus.py

@ -307,7 +307,7 @@ class MumbleCtlDbus_118(MumbleCtlBase):
srv.setPlayerState((session, ismute, deaf, suppressed, selfMute, selfDeaf, channel)) srv.setPlayerState((session, ismute, deaf, suppressed, selfMute, selfDeaf, channel))
def addChannel( self, srvid, name, parentid ): def addChannel( self, srvid, name, parentid ):
return self._getDbusServerObject(srvid).addChannel( name.encode( "UTF-8" ), parentid )
return self._getDbusServerObject(srvid).addChannel( name, parentid )
def removeChannel( self, srvid, channelid ): def removeChannel( self, srvid, channelid ):
return self._getDbusServerObject(srvid).removeChannel( channelid ) return self._getDbusServerObject(srvid).removeChannel( channelid )
@ -323,6 +323,12 @@ class MumbleCtlDbus_118(MumbleCtlBase):
(chanid, name, parent, links) = srv.getChannelState(dbus.UInt32(channelid)) (chanid, name, parent, links) = srv.getChannelState(dbus.UInt32(channelid))
srv.setChannelState((chanid, name, parentid, links)) srv.setChannelState((chanid, name, parentid, links))
def sendMessage(self, srvid, sessionid, message):
return self._getDbusServerObject(srvid).sendMessage( dbus.UInt32(sessionid), message )
def sendMessageChannel(self, srvid, channelid, tree, message):
return self._getDbusServerObject(srvid).sendMessageChannel( dbus.UInt32(channelid), tree, message )
def getUptime( self, srvid): def getUptime( self, srvid):
return 0 return 0

8
pyweb/mumble/MumbleCtlIce.py

@ -477,6 +477,14 @@ class MumbleCtlIce_118(MumbleCtlBase):
state.deaf = deaf state.deaf = deaf
srv.setState(state) srv.setState(state)
@protectDjangoErrPage
def sendMessage(self, srvid, sessionid, message):
return self._getIceServerObject(srvid).sendMessage( sessionid, message.encode( "UTF-8" ) )
@protectDjangoErrPage
def sendMessageChannel(self, srvid, channelid, tree, message):
return self._getIceServerObject(srvid).sendMessageChannel( channelid, tree, message.encode( "UTF-8" ) )
class MumbleCtlIce_120(MumbleCtlIce_118): class MumbleCtlIce_120(MumbleCtlIce_118):
@protectDjangoErrPage @protectDjangoErrPage

42
pyweb/mumble/media/js/channelviewerplugins.js

@ -153,6 +153,25 @@ Ext.ux.MumbleUserEditor = Ext.extend( Ext.Component, {
btn.refOwner.mutebutton.setDisabled(state); btn.refOwner.mutebutton.setDisabled(state);
} }
}], }],
}, {
xtype: "form",
border: false,
title: gettext("Send message"),
defaults: { "anchor": "-20px" },
items: [{
xtype: "htmleditor",
fieldLabel: 'x',
hideLabel: true,
name: "message"
}],
fbar: [{
scope: this,
text: gettext("Send message"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.sendMessage(this.serverid, this.userdata.session, f.message);
}
}]
}], }],
}], }],
width: 500, width: 500,
@ -248,6 +267,29 @@ Ext.ux.MumbleChannelEditor = Ext.extend( Ext.Component, {
}, this); }, this);
} }
}] }]
}, {
xtype: "form",
border: false,
title: gettext("Send message"),
defaults: { "anchor": "-20px" },
items: [{
xtype: "checkbox",
fieldLabel: gettext('Cascade to subchannels'),
name: 'tree'
}, {
xtype: "htmleditor",
fieldLabel: 'x',
hideLabel: true,
name: "message"
}],
fbar: [{
scope: this,
text: gettext("Send message"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.sendMessageChannel(this.serverid, this.chandata.id, (f.tree || false), f.message);
}
}]
}], }],
}], }],
width: 500, width: 500,

6
pyweb/mumble/models.py

@ -574,6 +574,12 @@ class Mumble( models.Model ):
def deafenUser( self, sessionid, deafen=True ): def deafenUser( self, sessionid, deafen=True ):
return self.ctl.deafenUser( self.srvid, sessionid, deafen ) return self.ctl.deafenUser( self.srvid, sessionid, deafen )
def sendMessage( self, sessionid, message ):
return self.ctl.sendMessage( self.srvid, sessionid, message )
def sendMessageChannel( self, channelid, tree, message ):
return self.ctl.sendMessageChannel( self.srvid, channelid, tree, message )
def hasUserTexture( self, userid ): def hasUserTexture( self, userid ):
""" Check if this user has a texture set. """ """ Check if this user has a texture set. """
if userid == -1: if userid == -1:

14
pyweb/mumble/views.py

@ -308,6 +308,20 @@ def renameChannel( request, server, channelid, name, description ):
raise Exception( 'Access denied' ) raise Exception( 'Access denied' )
srv.renameChannel(channelid, name, description) srv.renameChannel(channelid, name, description)
@EXT_DIRECT_PROVIDER.register_method( "Mumble" )
def sendMessage( request, server, sessionid, message ):
srv = get_object_or_404( Mumble, id=int(server) )
if not srv.isUserAdmin( request.user ):
raise Exception( 'Access denied' )
srv.sendMessage(sessionid, message)
@EXT_DIRECT_PROVIDER.register_method( "Mumble" )
def sendMessageChannel( request, server, channelid, tree, message ):
srv = get_object_or_404( Mumble, id=int(server) )
if not srv.isUserAdmin( request.user ):
raise Exception( 'Access denied' )
srv.sendMessageChannel(channelid, tree, message)
@EXT_DIRECT_PROVIDER.register_method( "MumbleUserAdmin" ) @EXT_DIRECT_PROVIDER.register_method( "MumbleUserAdmin" )
def users( request, server ): def users( request, server ):
""" Create a list of MumbleUsers for a given server serialized as a JSON object. """ Create a list of MumbleUsers for a given server serialized as a JSON object.

Loading…
Cancel
Save