Global.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. #pragma once
  2. #include <stdio.h>
  3. #include <locale.h>
  4. #include <stdlib.h>
  5. #include <time.h> //或者 #include <ctime>
  6. #include <io.h>
  7. #pragma comment(lib, "version.lib")
  8. #include "../cJson/cJSON.h"
  9. #include "tinyxml2.h"
  10. #include <vector>
  11. #include <string>
  12. #include <map>
  13. namespace Global
  14. {
  15. //////////////////////////////////////////////////////////////////////////
  16. typedef struct __MIDINFO__
  17. {
  18. std::string order; // 订单号;
  19. std::string quantity; // 订单数量;
  20. std::string pid; //
  21. std::string ctype;
  22. std::string version;
  23. std::string purl;
  24. std::string psize;
  25. std::string pmd5;
  26. }STMidInfo, *pSTMidInfo;
  27. // 升级包返回体;
  28. typedef struct
  29. {
  30. std::string servertime;
  31. std::string callid;
  32. std::string status;
  33. std::string note;
  34. std::string language;
  35. std::string apiversion;
  36. typedef struct
  37. {
  38. std::string now;
  39. std::string type;
  40. std::string appid;
  41. std::string apptype;
  42. std::string version;
  43. std::string verid;
  44. std::string md5;
  45. std::string size;
  46. std::string minicon;
  47. std::string midicon;
  48. std::string fileurl;
  49. std::string increment;
  50. std::string appendver;
  51. std::string updatetime;
  52. } __upcontent__;
  53. __upcontent__ upcontent;
  54. } __update_result__;
  55. typedef struct CHASSIS
  56. {
  57. bool IsCopyDID;
  58. bool IsCopyMAC;
  59. bool IsCopyKEY;
  60. bool IsCopyESN;
  61. bool IsCopyWiDi;
  62. bool IsCopyWidevine;
  63. bool IsCopyKEY2_2;
  64. bool IsCopyKEY2_3;
  65. bool IsCopyCikey;
  66. bool IsCopyChannel;
  67. bool IsCopyWB;
  68. bool IsDisplayClientType;
  69. bool IsWritePID;
  70. bool IsWBInit;
  71. bool IsMTKInit;
  72. bool IsOsdLanguage;
  73. bool IsShopLanguage;
  74. bool IsCopyClientType;
  75. bool IsMGKKeyEnb;
  76. bool IsNovaTakHDCPEnb;
  77. int Delay;
  78. unsigned int ProjectID;
  79. std::string Channel;
  80. std::string WBFile;
  81. std::string CheckString;
  82. std::string ClientType;
  83. std::string MACType;
  84. std::string HDCPKeyType;
  85. std::string HDCPKey22Type;
  86. std::string HDCPKey23Type;
  87. std::string ESNType;
  88. std::string WiDiType;
  89. std::string WidevineType;
  90. std::string CIKeyType;
  91. std::string OsdLanguage;
  92. std::string ShopLanguage;
  93. std::string MGKKeyType;
  94. std::string NovaTakHDCPType;
  95. std::string url; // 在线服务器;
  96. std::string name; // chassis name;
  97. CHASSIS& operator=(const CHASSIS& that)
  98. {
  99. if (this != &that)
  100. {
  101. url = that.url;
  102. name = that.name;
  103. IsCopyDID = that.IsCopyDID;
  104. IsCopyMAC = that.IsCopyMAC;
  105. IsCopyKEY = that.IsCopyKEY;
  106. IsCopyESN = that.IsCopyESN;
  107. IsCopyWiDi = that.IsCopyWiDi;
  108. IsCopyWidevine = that.IsCopyWidevine;
  109. IsCopyKEY2_2 = that.IsCopyKEY2_2;
  110. IsCopyKEY2_3 = that.IsCopyKEY2_3;
  111. IsCopyCikey = that.IsCopyCikey;
  112. IsCopyChannel = that.IsCopyChannel;
  113. IsCopyWB = that.IsCopyWB;
  114. IsDisplayClientType = that.IsDisplayClientType;
  115. IsWritePID = that.IsWritePID;
  116. IsWBInit = that.IsWBInit;
  117. IsMTKInit = that.IsMTKInit;
  118. IsOsdLanguage = that.IsOsdLanguage;
  119. IsShopLanguage = that.IsShopLanguage;
  120. IsCopyClientType = that.IsCopyClientType;
  121. IsMGKKeyEnb = that.IsMGKKeyEnb;
  122. IsNovaTakHDCPEnb = that.IsNovaTakHDCPEnb;
  123. Delay = that.Delay;
  124. ProjectID = that.ProjectID;
  125. Channel = that.Channel;
  126. WBFile = that.WBFile;
  127. CheckString = that.CheckString;
  128. ClientType = that.ClientType;
  129. MACType = that.MACType;
  130. HDCPKeyType = that.HDCPKeyType;
  131. HDCPKey22Type = that.HDCPKey22Type;
  132. HDCPKey23Type = that.HDCPKey23Type;
  133. ESNType = that.ESNType;
  134. WiDiType = that.WiDiType;
  135. WidevineType = that.WidevineType;
  136. CIKeyType = that.CIKeyType;
  137. OsdLanguage = that.OsdLanguage;
  138. ShopLanguage = that.ShopLanguage;
  139. MGKKeyType = that.MGKKeyType;
  140. NovaTakHDCPType = that.NovaTakHDCPType;
  141. }
  142. return *this;
  143. }
  144. } TChassis, * pTChassis;
  145. typedef struct __READCHECK__
  146. {
  147. bool IsPID;
  148. bool IsCHANNEL;
  149. bool IsOSD;
  150. bool IsSHOP;
  151. bool IsDID;
  152. bool IsMAC;
  153. bool IsHDCP;
  154. bool IsHDCP22;
  155. bool IsWIDI;
  156. bool IsWIDEVINE;
  157. bool IsESN;
  158. bool IsCI;
  159. }TReadCheck, * pTReadCheck;
  160. typedef struct __WRITECHECK__
  161. {
  162. //bool IsPID;
  163. //bool IsCHANNEL;
  164. //bool IsOSD;
  165. //bool IsSHOP;
  166. bool IsDID;
  167. bool IsMAC;
  168. bool IsHDCP;
  169. bool IsHDCP22;
  170. bool IsWIDI;
  171. bool IsWIDEVINE;
  172. bool IsESN;
  173. bool IsCI;
  174. }TWriteCheck, * pWriteCheck;
  175. typedef struct __WRITEDONE__
  176. {
  177. bool IsPID;
  178. bool IsCHANNEL;
  179. bool IsOSD;
  180. bool IsSHOP;
  181. bool IsDID;
  182. bool IsMAC;
  183. bool IsHDCP;
  184. bool IsHDCP22;
  185. bool IsWIDI;
  186. bool IsWIDEVINE;
  187. bool IsESN;
  188. bool IsCI;
  189. }TWriteDone, * pTWriteDone;
  190. extern Global::TChassis g_AutoOnlineChassis;
  191. // 配置文件;
  192. typedef struct TCONFIG
  193. {
  194. std::string com;
  195. std::string baudrate;
  196. std::string chassis;
  197. int mode;
  198. int warncount ;
  199. int waitboot;
  200. std::string siacpcmdfile;
  201. std::string serverurl;
  202. std::map<std::string, std::string> channel;
  203. std::map<std::string, std::string> language;
  204. std::map<std::string, std::string> keyfolder;
  205. std::map<std::string, TChassis> chassislist;
  206. TReadCheck readcheck;
  207. TWriteCheck writecheck;
  208. TWriteDone writedone;
  209. } TConfig, * pTConfig;
  210. // 网卡类型;
  211. enum NICKIND
  212. {
  213. // pci网卡;
  214. NIC_PCI,
  215. // usb网卡;
  216. NIC_USB,
  217. // 虚拟网卡;
  218. NIC_ROOT,
  219. // 仿真网卡;
  220. NIC_SWD,
  221. // 未知类型;
  222. NIC_UNK
  223. };
  224. typedef struct __MAC_ADDRESS__
  225. {
  226. INT nNICKind;
  227. TCHAR szNICKind[16];
  228. TCHAR szMacAddress[MAX_PATH];
  229. TCHAR szDevicePath[MAX_PATH];
  230. } MacAddress, * pMacAddress;
  231. //////////////////////////////////////////////////////////////////////////
  232. // 全局变量;
  233. extern BOOL g_bTestHost;
  234. extern TCHAR g_szCurModuleDir[MAX_PATH];
  235. extern TCHAR g_szCurModulePath[MAX_PATH];
  236. extern TCHAR g_szFna[MAX_PATH];
  237. extern TCHAR g_szConfig[MAX_PATH];
  238. extern std::string g_strMacs;
  239. extern std::vector<MacAddress> g_vtMac;
  240. extern TConfig g_tConfig;
  241. //////////////////////////////////////////////////////////////////////////
  242. // 全局函数;
  243. void Init();
  244. void MKDIR(LPCTSTR dir);
  245. void GetConfig();
  246. void SetConfig();
  247. bool GetVersion(IN const TCHAR* fname, OUT WORD* pdwFileVersion, OUT WORD* pdwProductVerion);
  248. BOOL GetVersion(IN HMODULE hModule, OUT DWORD(&dwFVArray)[4], OUT DWORD(&dwPVArray)[4]);
  249. void WriteTextLog(const TCHAR* format, ...);
  250. std::string EnCode_UTF8URL(IN const CHAR* pText);
  251. std::string& trim(std::string& str);
  252. // 获取网卡地址;
  253. INT GetMacAddress();
  254. // 字符串是否由数字、字母、符号组成;
  255. BOOL IsValidString(LPCTSTR lpszString);
  256. // 获取系统当前串口数量;
  257. BOOL GetSysSerialPort(std::vector<std::string>& vtports);
  258. }; // namespace Global