Browse Source

add channel functions: add/delete/change name, description. fixes #89

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
8a155895a4
  1. 12
      pyweb/mumble/MumbleCtlDbus.py
  2. 23
      pyweb/mumble/MumbleCtlIce.py
  3. 40
      pyweb/mumble/media/js/channelviewerplugins.js
  4. 9
      pyweb/mumble/models.py
  5. 4
      pyweb/mumble/templates/mumble/mumble.html
  6. 21
      pyweb/mumble/views.py

12
pyweb/mumble/MumbleCtlDbus.py

@ -306,6 +306,18 @@ class MumbleCtlDbus_118(MumbleCtlBase):
(session, ismute, isdeaf, suppressed, selfMute, selfDeaf, channel) = srv.getPlayerState(dbus.UInt32(sessionid)) (session, ismute, isdeaf, suppressed, selfMute, selfDeaf, channel) = srv.getPlayerState(dbus.UInt32(sessionid))
srv.setPlayerState((session, ismute, deaf, suppressed, selfMute, selfDeaf, channel)) 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 )
def removeChannel( self, srvid, channelid ):
return self._getDbusServerObject(srvid).removeChannel( channelid )
def renameChannel( self, srvid, channelid, name, description ):
srv = self._getDbusServerObject(srvid)
state = srv.getChannelState(channelid)
(chanid, oldname, parent, links) = srv.getChannelState(dbus.UInt32(channelid))
srv.setChannelState((chanid, name, parent, links))
def moveChannel(self, srvid, channelid, parentid): def moveChannel(self, srvid, channelid, parentid):
srv = self._getDbusServerObject(srvid) srv = self._getDbusServerObject(srvid)
(chanid, name, parent, links) = srv.getChannelState(dbus.UInt32(channelid)) (chanid, name, parent, links) = srv.getChannelState(dbus.UInt32(channelid))

23
pyweb/mumble/MumbleCtlIce.py

@ -434,6 +434,21 @@ class MumbleCtlIce_118(MumbleCtlBase):
def getLog( self, srvid, first=0, last=100 ): def getLog( self, srvid, first=0, last=100 ):
return self._getIceServerObject(srvid).getLog( first, last ) return self._getIceServerObject(srvid).getLog( first, last )
@protectDjangoErrPage
def addChannel( self, srvid, name, parentid ):
return self._getIceServerObject(srvid).addChannel( name.encode( "UTF-8" ), parentid )
@protectDjangoErrPage
def removeChannel( self, srvid, channelid ):
return self._getIceServerObject(srvid).removeChannel( channelid )
@protectDjangoErrPage
def renameChannel( self, srvid, channelid, name, description ):
srv = self._getIceServerObject(srvid)
state = srv.getChannelState(channelid)
state.name = name.encode("UTF-8")
srv.setChannelState(state)
@protectDjangoErrPage @protectDjangoErrPage
def moveChannel(self, srvid, channelid, parentid): def moveChannel(self, srvid, channelid, parentid):
srv = self._getIceServerObject(srvid) srv = self._getIceServerObject(srvid)
@ -602,6 +617,14 @@ class MumbleCtlIce_120(MumbleCtlIce_118):
def kickUser(self, srvid, userid, reason=""): def kickUser(self, srvid, userid, reason=""):
return self._getIceServerObject(srvid).kickUser( userid, reason.encode("UTF-8") ) return self._getIceServerObject(srvid).kickUser( userid, reason.encode("UTF-8") )
@protectDjangoErrPage
def renameChannel( self, srvid, channelid, name, description ):
srv = self._getIceServerObject(srvid)
state = srv.getChannelState(channelid)
state.name = name.encode("UTF-8")
state.description = description.encode("UTF-8")
srv.setChannelState(state)
@protectDjangoErrPage @protectDjangoErrPage
def getUptime(self, srvid): def getUptime(self, srvid):
return self._getIceServerObject(srvid).getUptime() return self._getIceServerObject(srvid).getUptime()

40
pyweb/mumble/media/js/channelviewerplugins.js

@ -150,6 +150,7 @@ Ext.ux.MumbleChannelEditor = Ext.extend( Ext.Component, {
activate: function( chandata ){ activate: function( chandata ){
if( !this.wnd ){ if( !this.wnd ){
this.chandata = chandata;
this.wnd = new Ext.Window({ this.wnd = new Ext.Window({
title: this.windowTitle || gettext("Channel details"), title: this.windowTitle || gettext("Channel details"),
layout: 'fit', layout: 'fit',
@ -162,12 +163,49 @@ Ext.ux.MumbleChannelEditor = Ext.extend( Ext.Component, {
title: gettext("Channel description"), title: gettext("Channel description"),
defaults: { "anchor": "-20px" }, defaults: { "anchor": "-20px" },
items: [{ items: [{
xtype: "textfield",
fieldLabel: "x",
hideLabel: true,
name: "name",
value: chandata.name
}, {
xtype: "htmleditor", xtype: "htmleditor",
fieldLabel: 'x', fieldLabel: 'x',
hideLabel: true, hideLabel: true,
name: "description", name: "description",
value: chandata.description,
value: chandata.description
}], }],
fbar: [{
text: gettext('Add subchannel...'),
scope: this,
handler: function(btn){
Ext.Msg.prompt(gettext('Name'), gettext('Please enter the channel name:'), function(btn, text){
if (btn == 'ok'){
Mumble.addChannel( this.serverid, text, this.chandata.id );
}
}, this);
}
}, {
scope: this,
text: gettext("Submit name/description"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.renameChannel(this.serverid, this.chandata.id, f.name, f.description);
}
}, {
text: gettext('Delete channel'),
scope: this,
handler: function(btn){
Ext.Msg.confirm(
gettext('Confirm channel deletion'),
gettext('Are you sure you want to delete channel x?'),
function(btn){
if( btn == 'yes' ){
Mumble.removeChannel( this.serverid, this.chandata.id );
}
}, this);
}
}]
}], }],
}], }],
width: 500, width: 500,

9
pyweb/mumble/models.py

@ -586,6 +586,15 @@ class Mumble( models.Model ):
def setUserTexture( self, userid, image ): def setUserTexture( self, userid, image ):
return self.ctl.setTexture( self.srvid, userid, image ) return self.ctl.setTexture( self.srvid, userid, image )
def addChannel( self, name, parentid ):
return self.ctl.addChannel( self.srvid, name, parentid )
def removeChannel( self, channelid ):
return self.ctl.removeChannel( self.srvid, channelid )
def renameChannel( self, channelid, name, description ):
return self.ctl.renameChannel( self.srvid, channelid, name, description )
def moveChannel( self, channelid, parentid ): def moveChannel( self, channelid, parentid ):
return self.ctl.moveChannel( self.srvid, channelid, parentid ) return self.ctl.moveChannel( self.srvid, channelid, parentid )

4
pyweb/mumble/templates/mumble/mumble.html

@ -79,7 +79,9 @@
new Ext.ux.MumbleUserEditor({ new Ext.ux.MumbleUserEditor({
serverid: {{MumbleServer.id}} serverid: {{MumbleServer.id}}
}), }),
new Ext.ux.MumbleChannelEditor()
new Ext.ux.MumbleChannelEditor({
serverid: {{MumbleServer.id}}
})
], ],
source_url: "{% url mumble.views.cvp_json MumbleServer.id %}", source_url: "{% url mumble.views.cvp_json MumbleServer.id %}",
imageurl: '{{MUMBLE_MEDIA_PREFIX}}/img', imageurl: '{{MUMBLE_MEDIA_PREFIX}}/img',

21
pyweb/mumble/views.py

@ -300,6 +300,27 @@ def deafenUser( request, server, sessionid, deaf ):
raise Exception( 'Access denied' ) raise Exception( 'Access denied' )
srv.deafenUser(sessionid, deaf) srv.deafenUser(sessionid, deaf)
@EXT_DIRECT_PROVIDER.register_method( "Mumble" )
def addChannel( request, server, name, parentid ):
srv = get_object_or_404( Mumble, id=int(server) )
if not srv.isUserAdmin( request.user ):
raise Exception( 'Access denied' )
srv.addChannel(name, parentid)
@EXT_DIRECT_PROVIDER.register_method( "Mumble" )
def removeChannel( request, server, channelid ):
srv = get_object_or_404( Mumble, id=int(server) )
if not srv.isUserAdmin( request.user ):
raise Exception( 'Access denied' )
srv.removeChannel(channelid)
@EXT_DIRECT_PROVIDER.register_method( "Mumble" )
def renameChannel( request, server, channelid, name, description ):
srv = get_object_or_404( Mumble, id=int(server) )
if not srv.isUserAdmin( request.user ):
raise Exception( 'Access denied' )
srv.renameChannel(channelid, name, description)
@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