neko/internal/websocket/handler/clipboard.go

24 lines
496 B
Go
Raw Permalink Normal View History

2020-12-01 05:40:38 +13:00
package handler
import (
2021-09-02 09:10:18 +12:00
"errors"
"github.com/demodesk/neko/pkg/types"
"github.com/demodesk/neko/pkg/types/message"
2020-12-01 05:40:38 +13:00
)
func (h *MessageHandlerCtx) clipboardSet(session types.Session, payload *message.ClipboardData) error {
2021-03-14 12:45:51 +13:00
if !session.Profile().CanAccessClipboard {
2021-09-02 09:10:18 +12:00
return errors.New("cannot access clipboard")
2020-12-07 06:55:24 +13:00
}
2020-12-01 05:40:38 +13:00
if !session.IsHost() {
2021-09-02 09:10:18 +12:00
return errors.New("is not the host")
2020-12-01 05:40:38 +13:00
}
return h.desktop.ClipboardSetText(types.ClipboardText{
Text: payload.Text,
// TODO: Send HTML?
})
2020-12-01 05:40:38 +13:00
}