XMPP modification because of lib modification
This commit is contained in:
parent
0d83871ec0
commit
75b320680f
20
xmpp/xmpp.go
20
xmpp/xmpp.go
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
|
|
||||||
"git.kingpenguin.tk/chteufleur/go-xmpp.git"
|
"git.kingpenguin.tk/chteufleur/go-xmpp.git/src/xmpp"
|
||||||
"git.kingpenguin.tk/chteufleur/datahouse.git/models"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models"
|
||||||
"git.kingpenguin.tk/chteufleur/datahouse.git/models/relay"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/relay"
|
||||||
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
||||||
|
|
@ -79,7 +79,7 @@ func mainXMPP() {
|
||||||
case *xmpp.Iq:
|
case *xmpp.Iq:
|
||||||
// TODO check if the caller has privilege to ask
|
// TODO check if the caller has privilege to ask
|
||||||
switch v.PayloadName().Space {
|
switch v.PayloadName().Space {
|
||||||
case xmpp.NsDiscoItems:
|
case xmpp.NSDiscoItems:
|
||||||
execDiscoCommand(v)
|
execDiscoCommand(v)
|
||||||
|
|
||||||
case xmpp.NodeAdHocCommand:
|
case xmpp.NodeAdHocCommand:
|
||||||
|
|
@ -104,7 +104,7 @@ func SendPresence(status, tpye, message string) {
|
||||||
|
|
||||||
func execDiscoCommand(iq *xmpp.Iq) {
|
func execDiscoCommand(iq *xmpp.Iq) {
|
||||||
log.Info("Discovery item iq received")
|
log.Info("Discovery item iq received")
|
||||||
reply := iq.Response(xmpp.IqTypeResult)
|
reply := iq.Response(xmpp.IQTypeResult)
|
||||||
discoItem := &xmpp.DiscoItems{Node: xmpp.NodeAdHocCommand}
|
discoItem := &xmpp.DiscoItems{Node: xmpp.NodeAdHocCommand}
|
||||||
|
|
||||||
relays := relay.GetAllRelay()
|
relays := relay.GetAllRelay()
|
||||||
|
|
@ -133,11 +133,11 @@ func execCommandAdHoc(iq *xmpp.Iq) {
|
||||||
if descriptionRelais == "" {
|
if descriptionRelais == "" {
|
||||||
descriptionRelais = relais.Mac
|
descriptionRelais = relais.Mac
|
||||||
}
|
}
|
||||||
if adHoc.SessionId == "" && adHoc.Action == xmpp.ActionAdHocExecute {
|
if adHoc.SessionID == "" && adHoc.Action == xmpp.ActionAdHocExecute {
|
||||||
// First step in the command
|
// First step in the command
|
||||||
if relais.Id != 0 {
|
if relais.Id != 0 {
|
||||||
reply := iq.Response(xmpp.IqTypeResult)
|
reply := iq.Response(xmpp.IQTypeResult)
|
||||||
cmd := &xmpp.AdHocCommand{Node: adHoc.Node, Status: xmpp.StatusAdHocExecute, SessionId: xmpp.SessionId()/*+";"+relais.Mac*/}
|
cmd := &xmpp.AdHocCommand{Node: adHoc.Node, Status: xmpp.StatusAdHocExecute, SessionID: xmpp.SessionID()/*+";"+relais.Mac*/}
|
||||||
|
|
||||||
cmdXForm := &xmpp.AdHocXForm{Type: xmpp.TypeAdHocForm, Title: "Commande relais "+descriptionRelais}
|
cmdXForm := &xmpp.AdHocXForm{Type: xmpp.TypeAdHocForm, Title: "Commande relais "+descriptionRelais}
|
||||||
field := &xmpp.AdHocField{Var: "command", Label: "Commande a executer", Type: "list-single"}
|
field := &xmpp.AdHocField{Var: "command", Label: "Commande a executer", Type: "list-single"}
|
||||||
|
|
@ -156,8 +156,8 @@ func execCommandAdHoc(iq *xmpp.Iq) {
|
||||||
|
|
||||||
err := relais.Toggle()
|
err := relais.Toggle()
|
||||||
|
|
||||||
reply := iq.Response(xmpp.IqTypeResult)
|
reply := iq.Response(xmpp.IQTypeResult)
|
||||||
cmd := &xmpp.AdHocCommand{Node: adHoc.Node, Status: xmpp.StatusAdHocCompleted, SessionId: adHoc.SessionId}
|
cmd := &xmpp.AdHocCommand{Node: adHoc.Node, Status: xmpp.StatusAdHocCompleted, SessionID: adHoc.SessionID}
|
||||||
|
|
||||||
cmdXForm := &xmpp.AdHocXForm{Type: xmpp.TypeAdHocResult, Title: "Commande relais "+descriptionRelais}
|
cmdXForm := &xmpp.AdHocXForm{Type: xmpp.TypeAdHocResult, Title: "Commande relais "+descriptionRelais}
|
||||||
cmd.XForm = *cmdXForm
|
cmd.XForm = *cmdXForm
|
||||||
|
|
@ -174,8 +174,8 @@ func execCommandAdHoc(iq *xmpp.Iq) {
|
||||||
client.Out <- reply
|
client.Out <- reply
|
||||||
} else if adHoc.Action == xmpp.ActionAdHocCancel {
|
} else if adHoc.Action == xmpp.ActionAdHocCancel {
|
||||||
// command canceled
|
// command canceled
|
||||||
reply := iq.Response(xmpp.IqTypeResult)
|
reply := iq.Response(xmpp.IQTypeResult)
|
||||||
cmd := &xmpp.AdHocCommand{Node: adHoc.Node, Status: xmpp.StatusAdHocCanceled, SessionId: adHoc.SessionId}
|
cmd := &xmpp.AdHocCommand{Node: adHoc.Node, Status: xmpp.StatusAdHocCanceled, SessionID: adHoc.SessionID}
|
||||||
reply.PayloadEncode(cmd)
|
reply.PayloadEncode(cmd)
|
||||||
client.Out <- reply
|
client.Out <- reply
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue