CApp.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #pragma once
  2. #include "CBaseMode.h"
  3. #include "CUserInfo.h"
  4. #include "CServerList.h"
  5. #include "CVersion.h"
  6. #include "CSysConfig.h"
  7. enum struct PROXY_MODE {
  8. sys_mode = 0,
  9. tun_mode,
  10. };
  11. enum struct ROUT_MODE{
  12. cn_mode = 0,
  13. qg_mode,
  14. };
  15. struct SysMode {
  16. int id;
  17. PROXY_MODE proxy_mode;
  18. SStringW name;
  19. };
  20. struct RouteMode {
  21. int id;
  22. ROUT_MODE route_mode;
  23. SStringW name;
  24. };
  25. class CApp : public SSingleton<CApp>
  26. {
  27. public:
  28. CApp();
  29. ~CApp();
  30. void Init();
  31. void UnInit();
  32. CSysConfig* CApp::GetSysconfig();
  33. CUserInfo* GetUserinfo();
  34. CServerList* GetServerList();
  35. CVersion* GetVerinfo();
  36. void SetOut(int out);
  37. int GetOut();
  38. void SetSysMode(PROXY_MODE mode);
  39. PROXY_MODE GetSysMode();
  40. void SetRouteMode(ROUT_MODE mode);
  41. ROUT_MODE GetRouteMode();
  42. void SetMethod(HINSTANCE hinst);
  43. HINSTANCE GetMethod();
  44. //¼ì²â»òÕßÉèÖÃDataĿ¼
  45. void ChkeAndSetDtaPath();
  46. bool CheckOnlyOneInstance() noexcept;
  47. std::filesystem::path GetDataPath();
  48. std::filesystem::path GetConfigPath();
  49. std::filesystem::path GetConfigGuiPath();
  50. void SetupDataDirectory();
  51. void SetCLashRuning(bool m);
  52. bool GetClashRuning();
  53. std::string GetToken() const { return m_token; }
  54. void SetToken(std::string val) { m_token = val; }
  55. std::string GetSelect_node() const;
  56. void SetSelect_node(std::string val);
  57. private:
  58. int m_is_out;
  59. CServerList* m_server_list;
  60. CUserInfo* m_userinfo;
  61. CVersion* m_versioninfo;
  62. CSysConfig* m_sys_config;
  63. PROXY_MODE m_proxy_mode;
  64. ROUT_MODE m_route_mode;
  65. HINSTANCE m_hInst;
  66. std::filesystem::path m_dataPath;
  67. std::filesystem::path m_configPath;
  68. std::filesystem::path m_config_Gui_Path;
  69. bool m_clashRuning = true;
  70. std::string m_token;
  71. /**/
  72. std::string select_node;
  73. };