ScbcCopyKey.cpp 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414
  1. // ScbcCopyKey.cpp : 定义 DLL 应用程序的导出函数。
  2. //
  3. #include "stdafx.h"
  4. #include "ScbcCopyKey.h"
  5. #include "OTA.h"
  6. #include "CurlClient.h"
  7. #include "cJSON.h"
  8. #include "CharEncoding.h"
  9. #ifdef __MAKE_PYD__
  10. #include "Python.h"
  11. #endif
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #endif
  15. CSIACP g_objSiacp;
  16. std::string g_strData;
  17. std::string g_httpData;
  18. bool ReadKeyFile(const char *lpfile, std::string& data)
  19. {
  20. if (!lpfile || _taccess(lpfile, 0) == -1)
  21. return false;
  22. FILE* pf = NULL;
  23. if (_tfopen_s(&pf, lpfile, _T("rb")) == 0)
  24. {
  25. if (pf)
  26. {
  27. fseek(pf, 0, SEEK_END);
  28. size_t fs = ftell(pf);
  29. fseek(pf, 0, SEEK_SET);
  30. byte* pdata = (byte*)malloc(fs);
  31. if (pdata)
  32. {
  33. fread(pdata, fs, 1, pf);
  34. fclose(pf);
  35. data.append((char*)pdata, fs);
  36. free(pdata);
  37. return true;
  38. }
  39. fclose(pf);
  40. }
  41. }
  42. return false;
  43. }
  44. // 唯一的应用程序对象
  45. #ifdef __CONSOLE__
  46. CWinApp theApp;
  47. using namespace std;
  48. int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
  49. {
  50. int nRetCode = 0;
  51. // 初始化 MFC 并在失败时显示错误
  52. if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
  53. {
  54. // TODO: 更改错误代码以符合您的需要
  55. _tprintf(_T("错误: MFC 初始化失败\n"));
  56. nRetCode = 1;
  57. }
  58. else
  59. {
  60. std::string token = HTTP_Login("http://test.dsp.server.qhmoka.com/login", "auto", "123456", TRUE);
  61. if ( token.size() )
  62. {
  63. int userId = HTTP_GetUserId("http://test.dsp.server.qhmoka.com/api/automation/getUserId", token.c_str(), "MOKA-AF-MS6586-0000L", "fe6015c2966118d45e745d3bdeabc052f87e7847", "5c:ad:76:e0:55:79");
  64. }
  65. // TODO: 在此处为应用程序的行为编写代码。
  66. if ( Open(5, 115200, 8, 0, 1) )
  67. {
  68. if ( EnterFactory() )
  69. {
  70. /*printf("%d\n",GetProjectId());
  71. printf("%s\n",GetSoftVersion());
  72. printf("%s\n",GetDeviceId());
  73. printf("%s\n",GetClientType());
  74. printf("%s\n",GetMAC());
  75. printf("%s\n",GetHDCPKey());
  76. printf("%s\n",GetHDCPKey22());
  77. printf("%s\n",GetWidi());
  78. printf("%s\n",GetNetflixESN());
  79. printf("%s\n",GetWidevine());
  80. printf("%s\n",GetCiKey());
  81. printf("%s\n",GetOSDLanguage());
  82. printf("%s\n",GetShopLanguage());
  83. printf("%s\n",GetChannel());
  84. ShowFactoryMenu();
  85. HideFactoryMenu();
  86. ShowFactoryInformation();
  87. HideFactoryInformation();
  88. int min = 0;
  89. ReadAgingTime(min);
  90. */
  91. SetRedGainRegister(100);
  92. SetRedGainRegister(300);
  93. LeaveFactory();
  94. }
  95. else
  96. {
  97. printf("进入工厂模式失败\n");
  98. }
  99. Close();
  100. }
  101. else
  102. {
  103. printf("打开串口失败\n");
  104. }
  105. }
  106. system("pause");
  107. return nRetCode;
  108. }
  109. #endif
  110. #ifndef __MAKE_PYD__
  111. SCBCCOPYKEY_API BOOL Open(int nPort, DWORD dwBaudrate, BYTE ByteSize, BYTE Parity, BYTE StopBits)
  112. {
  113. return g_objSiacp.OpenComm(nPort, dwBaudrate);
  114. }
  115. SCBCCOPYKEY_API void Close()
  116. {
  117. g_objSiacp.CloseComm();
  118. }
  119. SCBCCOPYKEY_API BOOL IsOpen()
  120. {
  121. return g_objSiacp.IsOpen();
  122. }
  123. SCBCCOPYKEY_API BOOL EnterFactory()
  124. {
  125. return g_objSiacp.SCBC_EnterFactory();
  126. }
  127. SCBCCOPYKEY_API BOOL LeaveFactory()
  128. {
  129. return g_objSiacp.SCBC_LeaveFactory();
  130. }
  131. //////////////////////////////////////////////////////////////////////////
  132. // 读取;
  133. SCBCCOPYKEY_API INT GetProjectId()
  134. {
  135. int pid = 0;
  136. if ( g_objSiacp.SCBC_GetProjectId(pid) )
  137. return pid;
  138. // 获取失败返回-1;
  139. return -1;
  140. }
  141. SCBCCOPYKEY_API LPCTSTR GetSoftVersion()
  142. {
  143. g_strData.clear();
  144. if ( g_objSiacp.SCBC_GetSoftVersion(g_strData) )
  145. return g_strData.c_str();
  146. return _T("");
  147. }
  148. SCBCCOPYKEY_API LPCTSTR GetDeviceId()
  149. {
  150. g_strData.clear();
  151. if ( g_objSiacp.SCBC_GetDeviceId(g_strData) )
  152. return g_strData.c_str();
  153. return _T("");
  154. }
  155. SCBCCOPYKEY_API LPCTSTR GetClientType()
  156. {
  157. g_strData.clear();
  158. if ( g_objSiacp.SCBC_GetClientType(g_strData) )
  159. return g_strData.c_str();
  160. return _T("");
  161. }
  162. SCBCCOPYKEY_API LPCTSTR GetMAC()
  163. {
  164. g_strData.clear();
  165. if ( g_objSiacp.SCBC_GetMAC(g_strData) )
  166. return g_strData.c_str();
  167. return _T("");
  168. }
  169. SCBCCOPYKEY_API LPCTSTR GetHDCPKey()
  170. {
  171. g_strData.clear();
  172. if ( g_objSiacp.SCBC_GetHDCPKey(g_strData) )
  173. return g_strData.c_str();
  174. return _T("");
  175. }
  176. SCBCCOPYKEY_API LPCTSTR GetHDCPKey22()
  177. {
  178. g_strData.clear();
  179. if ( g_objSiacp.SCBC_GetHDCPKey22(g_strData) )
  180. return g_strData.c_str();
  181. return _T("");
  182. }
  183. SCBCCOPYKEY_API LPCTSTR GetWidi()
  184. {
  185. g_strData.clear();
  186. if ( g_objSiacp.SCBC_GetWidi(g_strData) )
  187. return g_strData.c_str();
  188. return _T("");
  189. }
  190. SCBCCOPYKEY_API LPCTSTR GetNetflixESN()
  191. {
  192. g_strData.clear();
  193. if ( g_objSiacp.SCBC_GetNetflixESN(g_strData) )
  194. return g_strData.c_str();
  195. return _T("");
  196. }
  197. SCBCCOPYKEY_API LPCTSTR GetWidevine()
  198. {
  199. g_strData.clear();
  200. if ( g_objSiacp.SCBC_GetWidevine(g_strData) )
  201. return g_strData.c_str();
  202. return _T("");
  203. }
  204. SCBCCOPYKEY_API LPCTSTR GetCiKey()
  205. {
  206. g_strData.clear();
  207. if ( g_objSiacp.SCBC_GetCiKey(g_strData) )
  208. return g_strData.c_str();
  209. return _T("");
  210. }
  211. SCBCCOPYKEY_API LPCTSTR GetOSDLanguage()
  212. {
  213. g_strData.clear();
  214. if ( g_objSiacp.SCBC_GetOSDLanguage(g_strData) )
  215. return g_strData.c_str();
  216. return _T("");
  217. }
  218. SCBCCOPYKEY_API LPCTSTR GetShopLanguage()
  219. {
  220. g_strData.clear();
  221. if ( g_objSiacp.SCBC_GetShopLanguage(g_strData) )
  222. return g_strData.c_str();
  223. return _T("");
  224. }
  225. SCBCCOPYKEY_API LPCTSTR GetChannel()
  226. {
  227. g_strData.clear();
  228. if ( g_objSiacp.SCBC_GetChannel(g_strData) )
  229. return g_strData.c_str();
  230. return _T("");
  231. }
  232. //////////////////////////////////////////////////////////////////////////
  233. // 设置;
  234. SCBCCOPYKEY_API BOOL SetProjectId(int pid)
  235. {
  236. return g_objSiacp.SCBC_SetProjectId(pid);
  237. }
  238. SCBCCOPYKEY_API BOOL SetProjectId(LPCTSTR lpPid)
  239. {
  240. if ( lpPid == NULL)
  241. return FALSE;
  242. return g_objSiacp.SCBC_SetProjectId(lpPid);
  243. }
  244. SCBCCOPYKEY_API BOOL SetProjectId(const byte* pBuffer, const int& nLen)
  245. {
  246. return g_objSiacp.SCBC_SetProjectId(pBuffer, nLen);
  247. }
  248. SCBCCOPYKEY_API BOOL SetDeviceId(LPCTSTR lpDeviceId)
  249. {
  250. if ( lpDeviceId == NULL)
  251. return FALSE;
  252. return g_objSiacp.SCBC_SetDeviceId(lpDeviceId);
  253. }
  254. SCBCCOPYKEY_API BOOL SetDeviceId(const byte* pBuffer, const int &nLen)
  255. {
  256. return g_objSiacp.SCBC_SetDeviceId(pBuffer, nLen);
  257. }
  258. SCBCCOPYKEY_API BOOL SetMAC(LPCTSTR lpMac)
  259. {
  260. if ( lpMac == NULL)
  261. return FALSE;
  262. return g_objSiacp.SCBC_SetMAC(lpMac);
  263. }
  264. SCBCCOPYKEY_API BOOL SetMAC(const byte* pBuffer, const int& nLen)
  265. {
  266. return g_objSiacp.SCBC_SetMAC(pBuffer, nLen);
  267. }
  268. SCBCCOPYKEY_API BOOL SetHDCPKey(LPCTSTR lpHDCP, BOOL bHasSpace)
  269. {
  270. if ( lpHDCP == NULL)
  271. return FALSE;
  272. return g_objSiacp.SCBC_SetHDCPKey(lpHDCP, bHasSpace);
  273. }
  274. SCBCCOPYKEY_API BOOL SetHDCPKey(const byte* pBuffer, const int& nLen)
  275. {
  276. return g_objSiacp.SCBC_SetHDCPKey(pBuffer, nLen);
  277. }
  278. SCBCCOPYKEY_API BOOL SetHDCPKey22(LPCTSTR lpHDCP22, BOOL bHasSpace)
  279. {
  280. if ( lpHDCP22 == NULL)
  281. return FALSE;
  282. return g_objSiacp.SCBC_SetHDCPKey22(lpHDCP22, bHasSpace);
  283. }
  284. SCBCCOPYKEY_API BOOL SetHDCPKey22(const byte* pBuffer, const int& nLen)
  285. {
  286. return g_objSiacp.SCBC_SetHDCPKey22(pBuffer, nLen);
  287. }
  288. SCBCCOPYKEY_API BOOL SetNetflixESN(LPCTSTR lpESN, BOOL bHasSpace)
  289. {
  290. if ( lpESN == NULL)
  291. return FALSE;
  292. return g_objSiacp.SCBC_SetNetflixESN(lpESN, bHasSpace);
  293. }
  294. SCBCCOPYKEY_API BOOL SetNetflixESN(const byte* pBuffer, const int& nLen)
  295. {
  296. return g_objSiacp.SCBC_SetNetflixESN(pBuffer, nLen);
  297. }
  298. SCBCCOPYKEY_API BOOL SetWidi(LPCTSTR lpWidi, BOOL bHasSpace)
  299. {
  300. if ( lpWidi == NULL)
  301. return FALSE;
  302. return g_objSiacp.SCBC_SetWidi(lpWidi, bHasSpace);
  303. }
  304. SCBCCOPYKEY_API BOOL SetWidi(const byte* pBuffer, const int& nLen)
  305. {
  306. return g_objSiacp.SCBC_SetWidi(pBuffer, nLen);
  307. }
  308. SCBCCOPYKEY_API BOOL SetWidevine(LPCTSTR lpWidevine, BOOL bHasSpace)
  309. {
  310. if ( lpWidevine == NULL)
  311. return FALSE;
  312. return g_objSiacp.SCBC_SetWidevine(lpWidevine, bHasSpace);
  313. }
  314. SCBCCOPYKEY_API BOOL SetWidevine(const byte* pBuffer, const int& nLen)
  315. {
  316. return g_objSiacp.SCBC_SetWidevine(pBuffer, nLen);
  317. }
  318. SCBCCOPYKEY_API BOOL SetCiKey(LPCTSTR lpCiKey, BOOL bHasSpace)
  319. {
  320. if ( lpCiKey == NULL)
  321. return FALSE;
  322. return g_objSiacp.SCBC_SetCiKey(lpCiKey, bHasSpace);
  323. }
  324. SCBCCOPYKEY_API BOOL SetCiKey(const byte* pBuffer, const int& nLen)
  325. {
  326. return g_objSiacp.SCBC_SetCiKey(pBuffer, nLen);
  327. }
  328. SCBCCOPYKEY_API BOOL SetOSDLanguage(LPCTSTR lan, BOOL bHasSpace)
  329. {
  330. if ( lan == NULL)
  331. return FALSE;
  332. return g_objSiacp.SCBC_SetOSDLanguage(lan, bHasSpace);
  333. }
  334. SCBCCOPYKEY_API BOOL SetOSDLanguage(const byte* pBuffer, const int& nLen)
  335. {
  336. return g_objSiacp.SCBC_SetOSDLanguage(pBuffer, nLen);
  337. }
  338. SCBCCOPYKEY_API BOOL SetShopLanguage(LPCTSTR lan, BOOL bHasSpace)
  339. {
  340. if ( lan == NULL)
  341. return FALSE;
  342. return g_objSiacp.SCBC_SetShopLanguage(lan, bHasSpace);
  343. }
  344. SCBCCOPYKEY_API BOOL SetShopLanguage(const byte* pBuffer, const int& nLen)
  345. {
  346. return g_objSiacp.SCBC_SetShopLanguage(pBuffer, nLen);
  347. }
  348. SCBCCOPYKEY_API BOOL SetChannel(LPCTSTR channel, BOOL bHasSpace)
  349. {
  350. if ( channel == NULL)
  351. return FALSE;
  352. return g_objSiacp.SCBC_SetChannel(channel, bHasSpace);
  353. }
  354. SCBCCOPYKEY_API BOOL SetChannel(const byte* pBuffer, const int& nLen)
  355. {
  356. return g_objSiacp.SCBC_SetChannel(pBuffer, nLen);
  357. }
  358. SCBCCOPYKEY_API BOOL SetWBNormal(LPCTSTR data)
  359. {
  360. if ( data == NULL)
  361. return FALSE;
  362. return g_objSiacp.SCBC_SetWBNormal(data);
  363. }
  364. SCBCCOPYKEY_API BOOL SetWBNormal(const byte* pBuffer, const int& nLen)
  365. {
  366. return g_objSiacp.SCBC_SetWBNormal(pBuffer, nLen);
  367. }
  368. SCBCCOPYKEY_API BOOL SetWBCool(LPCTSTR data)
  369. {
  370. if ( data == NULL)
  371. return FALSE;
  372. return g_objSiacp.SCBC_SetWBCool(data);
  373. }
  374. SCBCCOPYKEY_API BOOL SetWBCool(const byte* pBuffer, const int& nLen)
  375. {
  376. return g_objSiacp.SCBC_SetWBCool(pBuffer, nLen);
  377. }
  378. SCBCCOPYKEY_API BOOL SetWBWarm(LPCTSTR data)
  379. {
  380. if ( data == NULL)
  381. return FALSE;
  382. return g_objSiacp.SCBC_SetWBWarm(data);
  383. }
  384. SCBCCOPYKEY_API BOOL SetWBWarm(const byte* pBuffer, const int& nLen)
  385. {
  386. return g_objSiacp.SCBC_SetWBWarm(pBuffer, nLen);
  387. }
  388. //////////////////////////////////////////////////////////////////////////
  389. // 检验;
  390. SCBCCOPYKEY_API BOOL CheckDeviceId()
  391. {
  392. return g_objSiacp.SCBC_CheckDeviceId();
  393. }
  394. SCBCCOPYKEY_API BOOL CheckMAC()
  395. {
  396. return g_objSiacp.SCBC_CheckMAC();
  397. }
  398. SCBCCOPYKEY_API BOOL CheckHDCP()
  399. {
  400. return g_objSiacp.SCBC_CheckHDCP();
  401. }
  402. SCBCCOPYKEY_API BOOL CheckHDCP22()
  403. {
  404. return g_objSiacp.SCBC_CheckHDCP22();
  405. }
  406. SCBCCOPYKEY_API BOOL CheckNetflixESN()
  407. {
  408. return g_objSiacp.SCBC_CheckNetflixESN();
  409. }
  410. SCBCCOPYKEY_API BOOL CheckWidi()
  411. {
  412. return g_objSiacp.SCBC_CheckWidi();
  413. }
  414. SCBCCOPYKEY_API BOOL CheckWidevine()
  415. {
  416. return g_objSiacp.SCBC_CheckWidevine();
  417. }
  418. SCBCCOPYKEY_API BOOL CheckCikey()
  419. {
  420. return g_objSiacp.SCBC_CheckCikey();
  421. }
  422. SCBCCOPYKEY_API BOOL StarWarmUpMode()
  423. {
  424. return g_objSiacp.SCBC_StarWarmUpMode();
  425. }
  426. SCBCCOPYKEY_API BOOL StopWarmUpMode()
  427. {
  428. return g_objSiacp.SCBC_StopWarmUpMode();
  429. }
  430. SCBCCOPYKEY_API BOOL ShowFactoryMenu()
  431. {
  432. return g_objSiacp.SCBC_ShowFactoryMenu();
  433. }
  434. SCBCCOPYKEY_API BOOL HideFactoryMenu()
  435. {
  436. return g_objSiacp.SCBC_HideFactoryMenu();
  437. }
  438. SCBCCOPYKEY_API BOOL ShowFactoryInformation()
  439. {
  440. return g_objSiacp.SCBC_ShowFactoryInformation();
  441. }
  442. SCBCCOPYKEY_API BOOL HideFactoryInformation()
  443. {
  444. return g_objSiacp.SCBC_HideFactoryInformation();
  445. }
  446. SCBCCOPYKEY_API BOOL EnterAgingModel()
  447. {
  448. return g_objSiacp.SCBC_EnterAgingModel();
  449. }
  450. SCBCCOPYKEY_API BOOL LeaveAgingModel()
  451. {
  452. return g_objSiacp.SCBC_LeaveAgingModel();
  453. }
  454. SCBCCOPYKEY_API BOOL ReadAgingTime(int &min)
  455. {
  456. return g_objSiacp.SCBC_ReadAgingTime(min);
  457. }
  458. SCBCCOPYKEY_API BOOL SetRedGainRegister(int value)
  459. {
  460. return g_objSiacp.SCBC_SetRedGainRegister(value);
  461. }
  462. SCBCCOPYKEY_API BOOL SetGreenGainRegister(int value)
  463. {
  464. return g_objSiacp.SCBC_SetGreenGainRegister(value);
  465. }
  466. SCBCCOPYKEY_API BOOL SetBlueGainRegister(int value)
  467. {
  468. return g_objSiacp.SCBC_SetBlueGainRegister(value);
  469. }
  470. SCBCCOPYKEY_API BOOL SetRedOffsetRegister(int value)
  471. {
  472. return g_objSiacp.SCBC_SetRedOffsetRegister(value);
  473. }
  474. SCBCCOPYKEY_API BOOL SetGreenOffsetRegister(int value)
  475. {
  476. return g_objSiacp.SCBC_SetGreenOffsetRegister(value);
  477. }
  478. SCBCCOPYKEY_API BOOL SetBlueOffsetRegister(int value)
  479. {
  480. return g_objSiacp.SCBC_SetBlueOffsetRegister(value);
  481. }
  482. #else
  483. static PyObject* Open(PyObject* self, PyObject* args)
  484. {
  485. int nPort;
  486. int Baudrate;
  487. int ByteSize, Parity, StopBits;
  488. if (!PyArg_ParseTuple(args, "iiiii", &nPort, &Baudrate, &ByteSize, &Parity, &StopBits ))
  489. return NULL;
  490. return Py_BuildValue("b", (bool)g_objSiacp.OpenComm(nPort, Baudrate));
  491. }
  492. static PyObject* Close(PyObject* self, PyObject* args)
  493. {
  494. g_objSiacp.CloseComm();
  495. return Py_None;
  496. }
  497. static PyObject* IsOpen(PyObject* self, PyObject* args)
  498. {
  499. return Py_BuildValue("b", (bool)g_objSiacp.IsOpen());
  500. }
  501. static PyObject* EnterFactory(PyObject* self, PyObject* args)
  502. {
  503. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_EnterFactory());
  504. }
  505. static PyObject* LeaveFactory(PyObject* self, PyObject* args)
  506. {
  507. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_LeaveFactory());
  508. }
  509. //////////////////////////////////////////////////////////////////////////
  510. // 读取;
  511. static PyObject* GetProjectId(PyObject* self, PyObject* args)
  512. {
  513. int pid = -1;
  514. g_objSiacp.SCBC_GetProjectId(pid);
  515. // 获取失败返回-1;
  516. return Py_BuildValue("i", pid);
  517. }
  518. static PyObject* GetSoftVersion(PyObject* self, PyObject* args)
  519. {
  520. g_strData.clear();
  521. g_objSiacp.SCBC_GetSoftVersion(g_strData);
  522. // 获取失败返回"";
  523. return Py_BuildValue("s", g_strData.c_str());
  524. }
  525. static PyObject* GetDeviceId(PyObject* self, PyObject* args)
  526. {
  527. g_strData.clear();
  528. g_objSiacp.SCBC_GetDeviceId(g_strData);
  529. // 获取失败返回"";
  530. return Py_BuildValue("s", g_strData.c_str());
  531. }
  532. static PyObject* GetClientType(PyObject* self, PyObject* args)
  533. {
  534. g_strData.clear();
  535. g_objSiacp.SCBC_GetClientType(g_strData);
  536. // 获取失败返回"";
  537. return Py_BuildValue("s", g_strData.c_str());
  538. }
  539. static PyObject* GetMAC(PyObject* self, PyObject* args)
  540. {
  541. g_strData.clear();
  542. g_objSiacp.SCBC_GetMAC(g_strData);
  543. // 获取失败返回"";
  544. return Py_BuildValue("s", g_strData.c_str());
  545. }
  546. static PyObject* GetHDCPKey(PyObject* self, PyObject* args)
  547. {
  548. g_strData.clear();
  549. g_objSiacp.SCBC_GetHDCPKey(g_strData);
  550. // 获取失败返回"";
  551. return Py_BuildValue("s", g_strData.c_str());
  552. }
  553. static PyObject* GetHDCPKey22(PyObject* self, PyObject* args)
  554. {
  555. g_strData.clear();
  556. g_objSiacp.SCBC_GetHDCPKey22(g_strData);
  557. // 获取失败返回"";
  558. return Py_BuildValue("s", g_strData.c_str());
  559. }
  560. static PyObject* GetWidi(PyObject* self, PyObject* args)
  561. {
  562. g_strData.clear();
  563. g_objSiacp.SCBC_GetWidi(g_strData);
  564. // 获取失败返回"";
  565. return Py_BuildValue("s", g_strData.c_str());
  566. }
  567. static PyObject* GetNetflixESN(PyObject* self, PyObject* args)
  568. {
  569. g_strData.clear();
  570. g_objSiacp.SCBC_GetNetflixESN(g_strData);
  571. // 获取失败返回"";
  572. return Py_BuildValue("s", g_strData.c_str());
  573. }
  574. static PyObject* GetWidevine(PyObject* self, PyObject* args)
  575. {
  576. g_strData.clear();
  577. g_objSiacp.SCBC_GetWidevine(g_strData);
  578. // 获取失败返回"";
  579. return Py_BuildValue("s", g_strData.c_str());
  580. }
  581. static PyObject* GetCiKey(PyObject* self, PyObject* args)
  582. {
  583. g_strData.clear();
  584. g_objSiacp.SCBC_GetCiKey(g_strData);
  585. // 获取失败返回"";
  586. return Py_BuildValue("s", g_strData.c_str());
  587. }
  588. static PyObject* GetOSDLanguage(PyObject* self, PyObject* args)
  589. {
  590. g_strData.clear();
  591. g_objSiacp.SCBC_GetOSDLanguage(g_strData);
  592. // 获取失败返回"";
  593. return Py_BuildValue("s", g_strData.c_str());
  594. }
  595. static PyObject* GetShopLanguage(PyObject* self, PyObject* args)
  596. {
  597. g_strData.clear();
  598. g_objSiacp.SCBC_GetShopLanguage(g_strData);
  599. // 获取失败返回"";
  600. return Py_BuildValue("s", g_strData.c_str());
  601. }
  602. static PyObject* GetChannel(PyObject* self, PyObject* args)
  603. {
  604. g_strData.clear();
  605. g_objSiacp.SCBC_GetChannel(g_strData);
  606. // 获取失败返回"";
  607. return Py_BuildValue("s", g_strData.c_str());
  608. }
  609. //////////////////////////////////////////////////////////////////////////
  610. // 设置;
  611. static PyObject* SetProjectId(PyObject* self, PyObject* args)
  612. {
  613. int pid = 0;
  614. if (!PyArg_ParseTuple(args, "i", &pid))
  615. return NULL;
  616. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetProjectId(pid));
  617. }
  618. static PyObject* SetDeviceId(PyObject* self, PyObject* args)
  619. {
  620. const char* pszdata= 0;
  621. if (!PyArg_ParseTuple(args, "s", &pszdata))
  622. return NULL;
  623. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetDeviceId(pszdata));
  624. }
  625. static PyObject* SetDeviceIdBF(PyObject* self, PyObject* args)
  626. {
  627. const char* pszfile = 0;
  628. if (!PyArg_ParseTuple(args, "s", &pszfile))
  629. return NULL;
  630. // 打开文件;
  631. std::string data;
  632. if ( ReadKeyFile(pszfile, data) )
  633. {
  634. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetDeviceId((BYTE*)data.c_str(), data.size()));
  635. }
  636. return Py_BuildValue("b", false);
  637. }
  638. static PyObject* SetMAC(PyObject* self, PyObject* args)
  639. {
  640. const char* pszdata = 0;
  641. if (!PyArg_ParseTuple(args, "s", &pszdata))
  642. return NULL;
  643. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetMAC(pszdata));
  644. }
  645. static PyObject* SetMACBF(PyObject* self, PyObject* args)
  646. {
  647. const char* pszfile = 0;
  648. if (!PyArg_ParseTuple(args, "s", &pszfile))
  649. return NULL;
  650. // 打开文件;
  651. std::string data;
  652. if ( ReadKeyFile(pszfile, data) )
  653. {
  654. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetMAC((BYTE*)data.c_str(), data.size()));
  655. }
  656. return Py_BuildValue("b", false);
  657. }
  658. static PyObject* SetHDCPKey(PyObject* self, PyObject* args)
  659. {
  660. BOOL bHasSpace;
  661. const char* pszdata = 0;
  662. if (!PyArg_ParseTuple(args, "sb", &pszdata, &bHasSpace))
  663. return NULL;
  664. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetHDCPKey(pszdata, bHasSpace));
  665. }
  666. static PyObject* SetHDCPKeyBF(PyObject* self, PyObject* args)
  667. {
  668. const char* pszfile = 0;
  669. if (!PyArg_ParseTuple(args, "s", &pszfile))
  670. return NULL;
  671. // 打开文件;
  672. std::string data;
  673. if ( ReadKeyFile(pszfile, data) )
  674. {
  675. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetHDCPKey((BYTE*)data.c_str(), data.size()));
  676. }
  677. return Py_BuildValue("b", false);
  678. }
  679. static PyObject* SetHDCPKey22(PyObject* self, PyObject* args)
  680. {
  681. BOOL bHasSpace;
  682. const char* pszdata = 0;
  683. if (!PyArg_ParseTuple(args, "sb", &pszdata, &bHasSpace))
  684. return NULL;
  685. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetHDCPKey22(pszdata, bHasSpace));
  686. }
  687. static PyObject* SetHDCPKey22BF(PyObject* self, PyObject* args)
  688. {
  689. const char* pszfile = 0;
  690. if (!PyArg_ParseTuple(args, "s", &pszfile))
  691. return NULL;
  692. // 打开文件;
  693. std::string data;
  694. if ( ReadKeyFile(pszfile, data) )
  695. {
  696. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetHDCPKey22((BYTE*)data.c_str(), data.size()));
  697. }
  698. return Py_BuildValue("b", false);
  699. }
  700. static PyObject* SetNetflixESN(PyObject* self, PyObject* args)
  701. {
  702. BOOL bHasSpace;
  703. const char* pszdata = 0;
  704. if (!PyArg_ParseTuple(args, "sb", &pszdata, &bHasSpace))
  705. return NULL;
  706. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetNetflixESN(pszdata, bHasSpace));
  707. }
  708. static PyObject* SetNetflixESNBF(PyObject* self, PyObject* args)
  709. {
  710. const char* pszfile = 0;
  711. if (!PyArg_ParseTuple(args, "s", &pszfile))
  712. return NULL;
  713. // 打开文件;
  714. std::string data;
  715. if ( ReadKeyFile(pszfile, data) )
  716. {
  717. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetNetflixESN((BYTE*)data.c_str(), data.size()));
  718. }
  719. return Py_BuildValue("b", false);
  720. }
  721. static PyObject* SetWidi(PyObject* self, PyObject* args)
  722. {
  723. BOOL bHasSpace;
  724. const char* pszdata = 0;
  725. if (!PyArg_ParseTuple(args, "sb", &pszdata, &bHasSpace))
  726. return NULL;
  727. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetWidi(pszdata, bHasSpace));
  728. }
  729. static PyObject* SetWidiBF(PyObject* self, PyObject* args)
  730. {
  731. const char* pszfile = 0;
  732. if (!PyArg_ParseTuple(args, "s", &pszfile))
  733. return NULL;
  734. // 打开文件;
  735. std::string data;
  736. if ( ReadKeyFile(pszfile, data) )
  737. {
  738. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetWidi((BYTE*)data.c_str(), data.size()));
  739. }
  740. return Py_BuildValue("b", false);
  741. }
  742. static PyObject* SetWidevine(PyObject* self, PyObject* args)
  743. {
  744. BOOL bHasSpace;
  745. const char* pszdata = 0;
  746. if (!PyArg_ParseTuple(args, "sb", &pszdata, &bHasSpace))
  747. return NULL;
  748. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetWidevine(pszdata, bHasSpace));
  749. }
  750. static PyObject* SetWidevineBF(PyObject* self, PyObject* args)
  751. {
  752. const char* pszfile = 0;
  753. if (!PyArg_ParseTuple(args, "s", &pszfile))
  754. return NULL;
  755. // 打开文件;
  756. std::string data;
  757. if ( ReadKeyFile(pszfile, data) )
  758. {
  759. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetWidevine((BYTE*)data.c_str(), data.size()));
  760. }
  761. return Py_BuildValue("b", false);
  762. }
  763. static PyObject* SetCiKey(PyObject* self, PyObject* args)
  764. {
  765. BOOL bHasSpace;
  766. const char* pszdata = 0;
  767. if (!PyArg_ParseTuple(args, "sb", &pszdata, &bHasSpace))
  768. return NULL;
  769. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetCiKey(pszdata, bHasSpace));
  770. }
  771. static PyObject* SetCiKeyBF(PyObject* self, PyObject* args)
  772. {
  773. const char* pszfile = 0;
  774. if (!PyArg_ParseTuple(args, "s", &pszfile))
  775. return NULL;
  776. // 打开文件;
  777. std::string data;
  778. if ( ReadKeyFile(pszfile, data) )
  779. {
  780. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetCiKey((BYTE*)data.c_str(), data.size()));
  781. }
  782. return Py_BuildValue("b", false);
  783. }
  784. static PyObject* SetOSDLanguage(PyObject* self, PyObject* args)
  785. {
  786. BOOL bHasSpace;
  787. const char* pszdata = 0;
  788. if (!PyArg_ParseTuple(args, "sb", &pszdata, &bHasSpace))
  789. return NULL;
  790. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetOSDLanguage(pszdata, bHasSpace));
  791. }
  792. static PyObject* SetShopLanguage(PyObject* self, PyObject* args)
  793. {
  794. BOOL bHasSpace;
  795. const char* pszdata = 0;
  796. if (!PyArg_ParseTuple(args, "sb", &pszdata, &bHasSpace))
  797. return NULL;
  798. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetShopLanguage(pszdata, bHasSpace));
  799. }
  800. static PyObject* SetChannel(PyObject* self, PyObject* args)
  801. {
  802. int value = 0;
  803. if (!PyArg_ParseTuple(args, "i", &value))
  804. return NULL;
  805. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetChannel(value));
  806. }
  807. static PyObject* SetWBNormal(PyObject* self, PyObject* args)
  808. {
  809. const char* pszdata = 0;
  810. if (!PyArg_ParseTuple(args, "s", &pszdata))
  811. return NULL;
  812. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetWBNormal(pszdata));
  813. }
  814. static PyObject* SetWBCool(PyObject* self, PyObject* args)
  815. {
  816. const char* pszdata = 0;
  817. if (!PyArg_ParseTuple(args, "s", &pszdata))
  818. return NULL;
  819. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetWBCool(pszdata));
  820. }
  821. static PyObject* SetWBWarm(PyObject* self, PyObject* args)
  822. {
  823. const char* pszdata = 0;
  824. if (!PyArg_ParseTuple(args, "s", &pszdata))
  825. return NULL;
  826. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetWBWarm(pszdata));
  827. }
  828. //////////////////////////////////////////////////////////////////////////
  829. // 校验;
  830. static PyObject* CheckDeviceId(PyObject* self, PyObject* args)
  831. {
  832. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_CheckDeviceId());
  833. }
  834. static PyObject* CheckMAC(PyObject* self, PyObject* args)
  835. {
  836. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_CheckMAC());
  837. }
  838. static PyObject* CheckHDCP(PyObject* self, PyObject* args)
  839. {
  840. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_CheckHDCP());
  841. }
  842. static PyObject* CheckHDCP22(PyObject* self, PyObject* args)
  843. {
  844. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_CheckHDCP22());
  845. }
  846. static PyObject* CheckNetflixESN(PyObject* self, PyObject* args)
  847. {
  848. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_CheckNetflixESN());
  849. }
  850. static PyObject* CheckWidi(PyObject* self, PyObject* args)
  851. {
  852. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_CheckWidi());
  853. }
  854. static PyObject* CheckWidevine(PyObject* self, PyObject* args)
  855. {
  856. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_CheckWidevine());
  857. }
  858. static PyObject* CheckCikey(PyObject* self, PyObject* args)
  859. {
  860. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_CheckCikey());
  861. }
  862. static PyObject* StarWarmUpMode(PyObject* self, PyObject* args)
  863. {
  864. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_StarWarmUpMode());
  865. }
  866. static PyObject* StopWarmUpMode(PyObject* self, PyObject* args)
  867. {
  868. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_StopWarmUpMode());
  869. }
  870. //
  871. static PyObject* ShowFactoryMenu(PyObject* self, PyObject* args)
  872. {
  873. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_ShowFactoryMenu());
  874. }
  875. static PyObject* HideFactoryMenu(PyObject* self, PyObject* args)
  876. {
  877. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_HideFactoryMenu());
  878. }
  879. static PyObject* ShowFactoryInformation(PyObject* self, PyObject* args)
  880. {
  881. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_ShowFactoryInformation());
  882. }
  883. static PyObject* HideFactoryInformation(PyObject* self, PyObject* args)
  884. {
  885. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_HideFactoryInformation());
  886. }
  887. static PyObject* EnterAgingModel(PyObject* self, PyObject* args)
  888. {
  889. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_EnterAgingModel());
  890. }
  891. static PyObject* LeaveAgingModel(PyObject* self, PyObject* args)
  892. {
  893. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_LeaveAgingModel());
  894. }
  895. static PyObject* ReadAgingTime(PyObject* self, PyObject* args)
  896. {
  897. int min = 0;
  898. if ( !g_objSiacp.SCBC_ReadAgingTime(min) )
  899. return Py_BuildValue("i", -1);
  900. return Py_BuildValue("i", min);
  901. }
  902. static PyObject* SetRedGainRegister(PyObject* self, PyObject* args)
  903. {
  904. int value = 0;
  905. if (!PyArg_ParseTuple(args, "i", &value))
  906. return NULL;
  907. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetRedGainRegister(value));
  908. }
  909. static PyObject* SetGreenGainRegister(PyObject* self, PyObject* args)
  910. {
  911. int value = 0;
  912. if (!PyArg_ParseTuple(args, "i", &value))
  913. return NULL;
  914. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetGreenGainRegister(value));
  915. }
  916. static PyObject* SetBlueGainRegister(PyObject* self, PyObject* args)
  917. {
  918. int value = 0;
  919. if (!PyArg_ParseTuple(args, "i", &value))
  920. return NULL;
  921. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetBlueGainRegister(value));
  922. }
  923. static PyObject* SetRedOffsetRegister(PyObject* self, PyObject* args)
  924. {
  925. int value = 0;
  926. if (!PyArg_ParseTuple(args, "i", &value))
  927. return NULL;
  928. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetRedOffsetRegister(value));
  929. }
  930. static PyObject* SetGreenOffsetRegister(PyObject* self, PyObject* args)
  931. {
  932. int value = 0;
  933. if (!PyArg_ParseTuple(args, "i", &value))
  934. return NULL;
  935. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetGreenOffsetRegister(value));
  936. }
  937. static PyObject* SetBlueOffsetRegister(PyObject* self, PyObject* args)
  938. {
  939. int value = 0;
  940. if (!PyArg_ParseTuple(args, "i", &value))
  941. return NULL;
  942. return Py_BuildValue("b", (bool)g_objSiacp.SCBC_SetBlueOffsetRegister(value));
  943. }
  944. static PyObject* HTTPLogin(PyObject* self, PyObject* args)
  945. {
  946. int rememberMe = 0;
  947. const char* pszhost = NULL;
  948. const char* pszUserName = NULL;
  949. const char* pszPassword = NULL;
  950. if (!PyArg_ParseTuple(args, "sssb", &pszhost, &pszUserName, &pszPassword, &rememberMe))
  951. return NULL;
  952. HTTP_Login(pszhost, pszUserName, pszPassword, rememberMe);
  953. return Py_BuildValue("s", g_httpData.c_str());
  954. }
  955. static PyObject* HTTPGetUserId(PyObject* self, PyObject* args)
  956. {
  957. const char* pszhost = NULL;
  958. const char* pszToken = NULL;
  959. const char* pszClientType = NULL;
  960. const char* pszDeviceId = NULL;
  961. const char* pszMAC = NULL;
  962. if (!PyArg_ParseTuple(args, "sssss", &pszhost, &pszToken, &pszClientType, &pszDeviceId, &pszMAC))
  963. return NULL;
  964. int userId = HTTP_GetUserId(pszhost, pszToken, pszClientType, pszDeviceId, pszMAC);
  965. return Py_BuildValue("i", userId);
  966. }
  967. // 描述方法,暴露给python的函数;
  968. static PyMethodDef ScbcCopyKey_Methods[] = {
  969. {"Open",Open,METH_VARARGS,"打开串口"},
  970. {"Close", Close, METH_VARARGS, "关闭串口"},
  971. {"IsOpen", IsOpen, METH_VARARGS, "串口是否打开"},
  972. {"EnterFactory", EnterFactory, METH_VARARGS, "进入工厂模式"},
  973. {"LeaveFactory", LeaveFactory, METH_VARARGS, "离开工厂模式"},
  974. //////////////////////////////////////////////////////////////////////////
  975. // 读取;
  976. {"GetProjectId", GetProjectId, METH_VARARGS, "获取pid"},
  977. {"GetSoftVersion", GetSoftVersion, METH_VARARGS, "获取版本号"},
  978. {"GetDeviceId", GetDeviceId, METH_VARARGS, "获取DeviceID"},
  979. {"GetClientType", GetClientType, METH_VARARGS, "获取ClientType"},
  980. {"GetMAC", GetMAC, METH_VARARGS, "获取MAC"},
  981. {"GetHDCPKey", GetHDCPKey, METH_VARARGS, "获取HDCP"},
  982. {"GetHDCPKey22", GetHDCPKey22, METH_VARARGS, "获取HDCP22"},
  983. {"GetWidi", GetWidi, METH_VARARGS, "获取WIDI"},
  984. {"GetNetflixESN", GetNetflixESN, METH_VARARGS, "获取ESN"},
  985. {"GetWidevine", GetWidevine, METH_VARARGS, "获取WIDEVINE"},
  986. {"GetCiKey", GetCiKey, METH_VARARGS, "获取CIKEY"},
  987. {"GetOSDLanguage", GetOSDLanguage, METH_VARARGS, "获取OSDLAN"},
  988. {"GetShopLanguage", GetShopLanguage, METH_VARARGS, "获取SHOPLAN"},
  989. {"GetChannel", GetChannel, METH_VARARGS, "获取频道号"},
  990. //////////////////////////////////////////////////////////////////////////
  991. // 设置;
  992. {"SetProjectId", SetProjectId, METH_VARARGS, "设置pid"},
  993. {"SetDeviceId", SetDeviceId, METH_VARARGS, "设置DeviceId"},
  994. {"SetDeviceIdBF", SetDeviceIdBF, METH_VARARGS, "设置DeviceId"},
  995. {"SetMAC", SetMAC, METH_VARARGS, "设置MAC"},
  996. {"SetMACBF", SetMACBF, METH_VARARGS, "设置MAC"},
  997. {"SetHDCPKey", SetHDCPKey, METH_VARARGS, "设置HDCP"},
  998. {"SetHDCPKeyBF", SetHDCPKeyBF, METH_VARARGS, "设置HDCP"},
  999. {"SetHDCPKey22", SetHDCPKey22, METH_VARARGS, "设置HDCP22"},
  1000. {"SetHDCPKey22BF", SetHDCPKey22BF, METH_VARARGS, "设置HDCP22"},
  1001. {"SetWidi", SetWidi, METH_VARARGS, "设置WIDI"},
  1002. {"SetWidiBF", SetWidiBF, METH_VARARGS, "设置WIDI"},
  1003. {"SetNetflixESN", SetNetflixESN, METH_VARARGS, "设置ESN"},
  1004. {"SetNetflixESNBF", SetNetflixESNBF, METH_VARARGS, "设置ESN"},
  1005. {"SetWidevine", SetWidevine, METH_VARARGS, "设置WIDEVINE"},
  1006. {"SetWidevineBF", SetWidevineBF, METH_VARARGS, "设置WIDEVINE"},
  1007. {"SetCiKey", SetCiKey, METH_VARARGS, "设置CIKEY"},
  1008. {"SetCiKeyBF", SetCiKeyBF, METH_VARARGS, "设置CIKEY"},
  1009. {"SetOSDLanguage", SetOSDLanguage, METH_VARARGS, "设置OSDLAN"},
  1010. {"SetShopLanguage", SetShopLanguage, METH_VARARGS, "设置SHOPLAN"},
  1011. {"SetChannel", SetChannel, METH_VARARGS, "设置频道号"},
  1012. {"SetWBNormal", SetWBNormal, METH_VARARGS, "设置OSDLAN"},
  1013. {"SetWBCool", SetWBCool, METH_VARARGS, "设置SHOPLAN"},
  1014. {"SetWBWarm", SetWBWarm, METH_VARARGS, "设置频道号"},
  1015. //////////////////////////////////////////////////////////////////////////
  1016. // 校验;
  1017. {"CheckDeviceId", CheckDeviceId, METH_VARARGS, "检验pid"},
  1018. {"CheckMAC", CheckMAC, METH_VARARGS, "检验MAC"},
  1019. {"CheckHDCP", CheckHDCP, METH_VARARGS, "检验HDCP"},
  1020. {"CheckHDCP22", CheckHDCP22, METH_VARARGS, "检验HDCP22"},
  1021. {"CheckWidi", CheckWidi, METH_VARARGS, "检验WIDI"},
  1022. {"CheckNetflixESN", CheckNetflixESN, METH_VARARGS, "检验ESN"},
  1023. {"CheckWidevine", CheckWidevine, METH_VARARGS, "检验WIDEVINE"},
  1024. {"CheckCikey", CheckCikey, METH_VARARGS, "检验CIKEY"},
  1025. {"StarWarmUpMode", StarWarmUpMode, METH_VARARGS, "检验OSDLAN"},
  1026. {"StopWarmUpMode", StopWarmUpMode, METH_VARARGS, "检验SHOPLAN"},
  1027. // others;
  1028. {"ShowFactoryMenu", ShowFactoryMenu, METH_VARARGS, "显示工厂菜单"},
  1029. {"HideFactoryMenu", HideFactoryMenu, METH_VARARGS, "隐藏工厂菜单"},
  1030. {"ShowFactoryInformation", ShowFactoryInformation, METH_VARARGS, "工厂信息内容显示"},
  1031. {"HideFactoryInformation", HideFactoryInformation, METH_VARARGS, "工厂信息内容隐藏"},
  1032. {"EnterAgingModel", EnterAgingModel, METH_VARARGS, "老化模式开"},
  1033. {"LeaveAgingModel", LeaveAgingModel, METH_VARARGS, "老化模式关"},
  1034. {"ReadAgingTime", ReadAgingTime, METH_VARARGS, "老化时间读取"},
  1035. {"SetRedGainRegister", SetRedGainRegister, METH_VARARGS, "红增益"},
  1036. {"SetGreenGainRegister", SetGreenGainRegister, METH_VARARGS, "绿增益"},
  1037. {"SetBlueGainRegister", SetBlueGainRegister, METH_VARARGS, "蓝增益"},
  1038. {"SetRedOffsetRegister", SetRedOffsetRegister, METH_VARARGS, "红偏移"},
  1039. {"SetGreenOffsetRegister", SetGreenOffsetRegister, METH_VARARGS, "绿偏移"},
  1040. {"SetBlueOffsetRegister", SetBlueOffsetRegister, METH_VARARGS, "蓝偏移"},
  1041. // HTTP
  1042. {"HTTPLogin", HTTPLogin, METH_VARARGS, "登录服务器"},
  1043. {"HTTPGetUserId", HTTPGetUserId, METH_VARARGS, "获取UserId"},
  1044. {NULL,NULL}
  1045. };
  1046. // 初始模块;//格式:init<模块名称>
  1047. PyMODINIT_FUNC initScbcCopyKey()
  1048. {
  1049. // 初始化pyd函数列表;
  1050. PyObject* m, * d;
  1051. m = Py_InitModule("ScbcCopyKey", ScbcCopyKey_Methods);
  1052. d = PyModule_GetDict(m);
  1053. }
  1054. #endif
  1055. SCBCCOPYKEY_API LPCTSTR HTTP_Login(LPCTSTR lpHost, LPCTSTR lpUserName, LPCTSTR lpPassword, BOOL bRemember)
  1056. {
  1057. if ( !lpHost || !lpUserName || !lpPassword )
  1058. return _T("");
  1059. CCurlClient curl;
  1060. if ( curl.Initialize() == CURLE_OK)
  1061. {
  1062. curl.SetHeaders("Content-Type: application/json;charset=utf-8");
  1063. // Json数据;
  1064. cJSON *pJson = cJSON_CreateObject();
  1065. cJSON_AddStringToObject(pJson, "username", lpUserName);
  1066. cJSON_AddStringToObject(pJson, "password", lpPassword);
  1067. cJSON_AddStringToObject(pJson, "rememberMe", bRemember ? "true" : "false");
  1068. char *pJsonText = cJSON_Print(pJson);
  1069. std::string result;
  1070. CURLcode curlCode = CURLE_OK;
  1071. if (_tcsstr(lpHost, "https://") || _tcsstr(lpHost, "HTTPS://") )
  1072. curlCode = curl.Posts(lpHost, pJsonText, result);
  1073. else
  1074. curlCode = curl.Posts(lpHost, pJsonText, result);
  1075. // 释放堆内存;
  1076. if (pJsonText)
  1077. delete pJsonText;
  1078. pJsonText = NULL;
  1079. if ( pJson )
  1080. cJSON_Delete(pJson);
  1081. pJson = NULL;
  1082. if ( curlCode == CURLE_OK )
  1083. {
  1084. result = CharEncoding::DeCode_URLUTF8(result.c_str());
  1085. // 解析返回值;
  1086. pJson = cJSON_Parse(result.c_str());
  1087. if (pJson != NULL)
  1088. {
  1089. int code = cJSON_GetObjectItem(pJson, "code") ? cJSON_GetObjectItem(pJson, "code")->valueint : -1;
  1090. std::string msg = cJSON_GetObjectItem(pJson, "msg") ? cJSON_GetObjectItem(pJson, "msg")->valuestring : "";
  1091. if ( code == 0 )
  1092. {
  1093. cJSON *pObj = cJSON_GetObjectItem(pJson, "data");
  1094. if (pObj != NULL)
  1095. {
  1096. g_httpData = cJSON_GetObjectItem(pObj, "token") ? cJSON_GetObjectItem(pObj, "token")->valuestring : "";
  1097. // 释放内存;
  1098. cJSON_Delete(pJson);
  1099. // 返回结果;
  1100. return g_httpData.c_str();
  1101. }
  1102. }
  1103. // 错误产生,可输出msg方便查询;
  1104. cJSON_Delete(pJson);
  1105. }
  1106. }
  1107. }
  1108. return _T("");
  1109. }
  1110. SCBCCOPYKEY_API int HTTP_GetUserId(LPCTSTR lpHost, LPCTSTR lpLoginToken, LPCTSTR lpClientType, LPCTSTR lpDeviceId, LPCTSTR lpMAC)
  1111. {
  1112. if ( !lpHost || !lpLoginToken || !lpClientType || !lpDeviceId || !lpMAC)
  1113. return -1;
  1114. CCurlClient curl;
  1115. if ( curl.Initialize() == CURLE_OK)
  1116. {
  1117. std::string header = "Authorization:";
  1118. header.append(lpLoginToken);
  1119. curl.SetHeaders(header);
  1120. curl.SetHeaders("Content-Type: application/json;charset=utf-8");
  1121. // Json数据;
  1122. cJSON *pJson = cJSON_CreateObject();
  1123. cJSON_AddStringToObject(pJson, "clientType", lpClientType);
  1124. cJSON_AddStringToObject(pJson, "deviceId", lpDeviceId);
  1125. cJSON_AddStringToObject(pJson, "mac", lpMAC);
  1126. char *pJsonText = cJSON_Print(pJson);
  1127. std::string result;
  1128. CURLcode curlCode = CURLE_OK;
  1129. if (_tcsstr(lpHost, "https://") || _tcsstr(lpHost, "HTTPS://") )
  1130. curlCode = curl.Posts(lpHost, pJsonText, result);
  1131. else
  1132. curlCode = curl.Posts(lpHost, pJsonText, result);
  1133. // 释放堆内存;
  1134. if (pJsonText)
  1135. delete pJsonText;
  1136. pJsonText = NULL;
  1137. if ( pJson )
  1138. cJSON_Delete(pJson);
  1139. pJson = NULL;
  1140. if ( curlCode == CURLE_OK )
  1141. {
  1142. result = CharEncoding::DeCode_URLUTF8(result.c_str());
  1143. // 解析返回值;
  1144. pJson = cJSON_Parse(result.c_str());
  1145. if (pJson != NULL)
  1146. {
  1147. int code = cJSON_GetObjectItem(pJson, "code") ? cJSON_GetObjectItem(pJson, "code")->valueint : -1;
  1148. std::string msg = cJSON_GetObjectItem(pJson, "msg") ? cJSON_GetObjectItem(pJson, "msg")->valuestring : "";
  1149. if ( code == 0 )
  1150. {
  1151. cJSON *pObj = cJSON_GetObjectItem(pJson, "data");
  1152. if (pObj != NULL)
  1153. {
  1154. int uiserId = cJSON_GetObjectItem(pObj, "userId") ? cJSON_GetObjectItem(pObj, "userId")->valueint : -1;
  1155. // 释放内存;
  1156. cJSON_Delete(pJson);
  1157. // 返回结果;
  1158. return uiserId;
  1159. }
  1160. }
  1161. // 错误产生,可输出msg方便查询;
  1162. cJSON_Delete(pJson);
  1163. }
  1164. }
  1165. }
  1166. return -1;
  1167. }