mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
clipboard lint fix.
This commit is contained in:
parent
b420841f9d
commit
7c305b5a27
@ -1,8 +1,9 @@
|
||||
package room
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
// TODO: Unused now.
|
||||
//"bytes"
|
||||
//"strings"
|
||||
"net/http"
|
||||
|
||||
"demodesk/neko/internal/utils"
|
||||
@ -14,16 +15,6 @@ type ClipboardPayload struct {
|
||||
HTML string `json:"html,omitempty"`
|
||||
}
|
||||
|
||||
func (h *RoomHandler) clipboardGetTargets(w http.ResponseWriter, r *http.Request) {
|
||||
targets, err := h.desktop.ClipboardGetTargets()
|
||||
if err != nil {
|
||||
utils.HttpInternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
utils.HttpSuccess(w, targets)
|
||||
}
|
||||
|
||||
func (h *RoomHandler) clipboardGetText(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := h.desktop.ClipboardGetText()
|
||||
if err != nil {
|
||||
@ -69,6 +60,7 @@ func (h *RoomHandler) clipboardGetImage(w http.ResponseWriter, r *http.Request)
|
||||
w.Write(bytes)
|
||||
}
|
||||
|
||||
/* TODO: Unused now.
|
||||
func (h *RoomHandler) clipboardSetImage(w http.ResponseWriter, r *http.Request) {
|
||||
err := r.ParseMultipartForm(MAX_UPLOAD_SIZE)
|
||||
if err != nil {
|
||||
@ -94,7 +86,11 @@ func (h *RoomHandler) clipboardSetImage(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
buffer.ReadFrom(file)
|
||||
_, err = buffer.ReadFrom(file)
|
||||
if err != nil {
|
||||
utils.HttpInternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = h.desktop.ClipboardSetBinary("image/png", buffer.Bytes())
|
||||
if err != nil {
|
||||
@ -104,3 +100,14 @@ func (h *RoomHandler) clipboardSetImage(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
utils.HttpSuccess(w)
|
||||
}
|
||||
|
||||
func (h *RoomHandler) clipboardGetTargets(w http.ResponseWriter, r *http.Request) {
|
||||
targets, err := h.desktop.ClipboardGetTargets()
|
||||
if err != nil {
|
||||
utils.HttpInternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
utils.HttpSuccess(w, targets)
|
||||
}
|
||||
*/
|
||||
|
@ -45,7 +45,7 @@ func (manager *DesktopManagerCtx) ClipboardGetBinary(mime string) ([]byte, error
|
||||
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
msg := strings.TrimSpace(string(stderr.Bytes()))
|
||||
msg := strings.TrimSpace(stderr.String())
|
||||
return nil, fmt.Errorf("%s", msg)
|
||||
}
|
||||
|
||||
@ -65,11 +65,15 @@ func (manager *DesktopManagerCtx) ClipboardSetBinary(mime string, data []byte) e
|
||||
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
msg := strings.TrimSpace(string(stderr.Bytes()))
|
||||
msg := strings.TrimSpace(stderr.String())
|
||||
return fmt.Errorf("%s", msg)
|
||||
}
|
||||
|
||||
stdin.Write(data)
|
||||
|
||||
_, err = stdin.Write(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
stdin.Close()
|
||||
|
||||
// TODO: Refactor.
|
||||
@ -86,12 +90,12 @@ func (manager *DesktopManagerCtx) ClipboardGetTargets() ([]string, error) {
|
||||
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
msg := strings.TrimSpace(string(stderr.Bytes()))
|
||||
msg := strings.TrimSpace(stderr.String())
|
||||
return nil, fmt.Errorf("%s", msg)
|
||||
}
|
||||
|
||||
var response []string
|
||||
targets := strings.Split(string(stdout.Bytes()), "\n")
|
||||
targets := strings.Split(stdout.String(), "\n")
|
||||
for _, target := range targets {
|
||||
if target == "" {
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user