aomodule.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "encoding/json"
  6. "os"
  7. )
  8. //Struct for storing module information
  9. type serviecInfo struct{
  10. Name string //Name of this module. e.g. "Audio"
  11. Desc string //Description for this module
  12. Group string //Group of the module, e.g. "system" / "media" etc
  13. IconPath string //Module icon image path e.g. "Audio/img/function_icon.png"
  14. Version string //Version of the module. Format: [0-9]*.[0-9][0-9].[0-9]
  15. StartDir string //Default starting dir, e.g. "Audio/index.html"
  16. SupportFW bool //Support floatWindow. If yes, floatWindow dir will be loaded
  17. LaunchFWDir string //This link will be launched instead of 'StartDir' if fw mode
  18. SupportEmb bool //Support embedded mode
  19. LaunchEmb string //This link will be launched instead of StartDir / Fw if a file is opened with this module
  20. InitFWSize []int //Floatwindow init size. [0] => Width, [1] => Height
  21. InitEmbSize []int //Embedded mode init size. [0] => Width, [1] => Height
  22. SupportedExt []string //Supported File Extensions. e.g. ".mp3", ".flac", ".wav"
  23. }
  24. func initaoModulePipeline(info serviecInfo) (string, bool){
  25. var infoRequestMode = flag.Bool("info", false, "Show information about this subservice")
  26. var port = flag.String("port", ":80", "The default listening endpoint for this subservice")
  27. var aoService = flag.Bool("aoservice", false, "Check if the system is running in aoservice mode")
  28. flag.Parse();
  29. if (*infoRequestMode == true){
  30. //Information request mode
  31. jsonString, _ := json.Marshal(info);
  32. fmt.Println(string(jsonString))
  33. os.Exit(0);
  34. }
  35. //Run mode. Continue to run the web services with given port
  36. return *port, *aoService;
  37. }