diff --git a/pyweb/mumble/MumbleCtlDbus.py b/pyweb/mumble/MumbleCtlDbus.py index 9596dc7..7766af0 100644 --- a/pyweb/mumble/MumbleCtlDbus.py +++ b/pyweb/mumble/MumbleCtlDbus.py @@ -307,7 +307,7 @@ class MumbleCtlDbus_118(MumbleCtlBase): srv.setPlayerState((session, ismute, deaf, suppressed, selfMute, selfDeaf, channel)) 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 ): return self._getDbusServerObject(srvid).removeChannel( channelid ) @@ -323,6 +323,12 @@ class MumbleCtlDbus_118(MumbleCtlBase): (chanid, name, parent, links) = srv.getChannelState(dbus.UInt32(channelid)) 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): return 0 diff --git a/pyweb/mumble/MumbleCtlIce.py b/pyweb/mumble/MumbleCtlIce.py index 0096d30..dd9c871 100644 --- a/pyweb/mumble/MumbleCtlIce.py +++ b/pyweb/mumble/MumbleCtlIce.py @@ -477,6 +477,14 @@ class MumbleCtlIce_118(MumbleCtlBase): state.deaf = deaf 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): @protectDjangoErrPage diff --git a/pyweb/mumble/media/js/channelviewerplugins.js b/pyweb/mumble/media/js/channelviewerplugins.js index ca722ca..11a271d 100644 --- a/pyweb/mumble/media/js/channelviewerplugins.js +++ b/pyweb/mumble/media/js/channelviewerplugins.js @@ -153,6 +153,25 @@ Ext.ux.MumbleUserEditor = Ext.extend( Ext.Component, { 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, @@ -248,6 +267,29 @@ Ext.ux.MumbleChannelEditor = Ext.extend( Ext.Component, { }, 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, diff --git a/pyweb/mumble/models.py b/pyweb/mumble/models.py index bedf2a7..db79ca7 100644 --- a/pyweb/mumble/models.py +++ b/pyweb/mumble/models.py @@ -574,6 +574,12 @@ class Mumble( models.Model ): def deafenUser( self, sessionid, deafen=True ): 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 ): """ Check if this user has a texture set. """ if userid == -1: diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index 184b348..9d3133e 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -308,6 +308,20 @@ def renameChannel( request, server, channelid, name, description ): raise Exception( 'Access denied' ) 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" ) def users( request, server ): """ Create a list of MumbleUsers for a given server serialized as a JSON object.