|
@@ -3,7 +3,6 @@ package main
|
|
import (
|
|
import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"errors"
|
|
"errors"
|
|
- "io/ioutil"
|
|
|
|
"log"
|
|
"log"
|
|
"net/http"
|
|
"net/http"
|
|
"os"
|
|
"os"
|
|
@@ -19,7 +18,7 @@ import (
|
|
"imuslab.com/arozos/mod/utils"
|
|
"imuslab.com/arozos/mod/utils"
|
|
)
|
|
)
|
|
|
|
|
|
-//Desktop script initiation
|
|
|
|
|
|
+// Desktop script initiation
|
|
func DesktopInit() {
|
|
func DesktopInit() {
|
|
systemWideLogger.PrintAndLog("Desktop", "Starting Desktop Services", nil)
|
|
systemWideLogger.PrintAndLog("Desktop", "Starting Desktop Services", nil)
|
|
|
|
|
|
@@ -67,9 +66,9 @@ func DesktopInit() {
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- FUNCTIONS RELATED TO PARSING DESKTOP FILE ICONS
|
|
|
|
|
|
+FUNCTIONS RELATED TO PARSING DESKTOP FILE ICONS
|
|
|
|
|
|
- The functions in this section handle file listing and its icon locations.
|
|
|
|
|
|
+The functions in this section handle file listing and its icon locations.
|
|
*/
|
|
*/
|
|
func desktop_initUserFolderStructure(username string) {
|
|
func desktop_initUserFolderStructure(username string) {
|
|
//Call to filesystem for creating user file struture at root dir
|
|
//Call to filesystem for creating user file struture at root dir
|
|
@@ -88,15 +87,15 @@ func desktop_initUserFolderStructure(username string) {
|
|
if fs.FileExists(templateFolder) {
|
|
if fs.FileExists(templateFolder) {
|
|
templateFiles, _ := filepath.Glob(templateFolder + "*")
|
|
templateFiles, _ := filepath.Glob(templateFolder + "*")
|
|
for _, tfile := range templateFiles {
|
|
for _, tfile := range templateFiles {
|
|
- input, _ := ioutil.ReadFile(tfile)
|
|
|
|
- ioutil.WriteFile(homedir+"Desktop/"+filepath.Base(tfile), input, 0755)
|
|
|
|
|
|
+ input, _ := os.ReadFile(tfile)
|
|
|
|
+ os.WriteFile(homedir+"Desktop/"+filepath.Base(tfile), input, 0755)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-//Return the information about the host
|
|
|
|
|
|
+// Return the information about the host
|
|
func desktop_hostdetailHandler(w http.ResponseWriter, r *http.Request) {
|
|
func desktop_hostdetailHandler(w http.ResponseWriter, r *http.Request) {
|
|
type returnStruct struct {
|
|
type returnStruct struct {
|
|
Hostname string
|
|
Hostname string
|
|
@@ -294,7 +293,7 @@ func desktop_listFiles(w http.ResponseWriter, r *http.Request) {
|
|
utils.SendJSONResponse(w, string(jsonString))
|
|
utils.SendJSONResponse(w, string(jsonString))
|
|
}
|
|
}
|
|
|
|
|
|
-//functions to handle desktop icon locations. Location is directly written into the center db.
|
|
|
|
|
|
+// functions to handle desktop icon locations. Location is directly written into the center db.
|
|
func getDesktopLocatioFromPath(filename string, username string) (int, int, error) {
|
|
func getDesktopLocatioFromPath(filename string, username string) (int, int, error) {
|
|
//As path include username, there is no different if there are username in the key
|
|
//As path include username, there is no different if there are username in the key
|
|
locationdata := ""
|
|
locationdata := ""
|
|
@@ -316,7 +315,7 @@ func getDesktopLocatioFromPath(filename string, username string) (int, int, erro
|
|
return thisFileLocation.X, thisFileLocation.Y, nil
|
|
return thisFileLocation.X, thisFileLocation.Y, nil
|
|
}
|
|
}
|
|
|
|
|
|
-//Set the icon location of a given filepath
|
|
|
|
|
|
+// Set the icon location of a given filepath
|
|
func setDesktopLocationFromPath(filename string, username string, x int, y int) error {
|
|
func setDesktopLocationFromPath(filename string, username string, x int, y int) error {
|
|
//You cannot directly set path of others people's deskop. Hence, fullpath needed to be parsed from auth username
|
|
//You cannot directly set path of others people's deskop. Hence, fullpath needed to be parsed from auth username
|
|
userinfo, _ := userHandler.GetUserInfoFromUsername(username)
|
|
userinfo, _ := userHandler.GetUserInfoFromUsername(username)
|
|
@@ -356,7 +355,7 @@ func delDesktopLocationFromPath(filename string, username string) {
|
|
sysdb.Delete("desktop", username+"/filelocation/"+filename)
|
|
sysdb.Delete("desktop", username+"/filelocation/"+filename)
|
|
}
|
|
}
|
|
|
|
|
|
-//Return the user information to the client
|
|
|
|
|
|
+// Return the user information to the client
|
|
func desktop_handleUserInfo(w http.ResponseWriter, r *http.Request) {
|
|
func desktop_handleUserInfo(w http.ResponseWriter, r *http.Request) {
|
|
userinfo, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
userinfo, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -404,7 +403,7 @@ func desktop_handleUserInfo(w http.ResponseWriter, r *http.Request) {
|
|
utils.SendJSONResponse(w, string(jsonString))
|
|
utils.SendJSONResponse(w, string(jsonString))
|
|
}
|
|
}
|
|
|
|
|
|
-//Icon handling function for web endpoint
|
|
|
|
|
|
+// Icon handling function for web endpoint
|
|
func desktop_fileLocation_handler(w http.ResponseWriter, r *http.Request) {
|
|
func desktop_fileLocation_handler(w http.ResponseWriter, r *http.Request) {
|
|
get, _ := utils.Mv(r, "get", true) //Check if there are get request for a given filepath
|
|
get, _ := utils.Mv(r, "get", true) //Check if there are get request for a given filepath
|
|
set, _ := utils.Mv(r, "set", true) //Check if there are any set request for a given filepath
|
|
set, _ := utils.Mv(r, "set", true) //Check if there are any set request for a given filepath
|