Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1252 lines
33 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996-1998
  5. //
  6. // File: LicPack.h
  7. //
  8. // Contents: LicensedPack Table
  9. //
  10. // History:
  11. //
  12. //---------------------------------------------------------------------------
  13. #ifndef __LICENSEDPACK_H__
  14. #define __LICENSEDPACK_H__
  15. #include "tlsdb.h"
  16. //
  17. // re-direct define using what's in tlsdef.h just for backward compatibility
  18. //
  19. #define LICENSEDPACK_PROCESS_DWINTERNAL LSKEYPACK_EXSEARCH_DWINTERNAL
  20. #define LICENSEDPACK_PROCESS_MODIFYTIME (LSKEYPACK_EXSEARCH_AVAILABLE << 1)
  21. //
  22. // Basic LicensedPack PROCESS Parameter
  23. //
  24. #define LICENSEDPACK_PROCESS_SZKEYPACKID LSKEYPACK_SEARCH_KEYPACKID // szKeyPackId
  25. #define LICENSEDPACK_PROCESS_AGREEMENTTYPE LSKEYPACK_SEARCH_KEYPACKTYPE // ucKeyPackType
  26. #define LICENSEDPACK_PROCESS_PRODUCTID LSKEYPACK_SEARCH_PRODUCTID // szProductId
  27. #define LICENSEDPACK_PROCESS_MAJORVERSION LSKEYPACK_SEARCH_MAJORVERSION // wMajorVersion
  28. #define LICENSEDPACK_PROCESS_MINORVERSION LSKEYPACK_SEARCH_MINORVERSION // wMinorVersion
  29. #define LICENSEDPACK_PROCESS_PLATFORMTYPE LSKEYPACK_SEARCH_PLATFORMTYPE // dwPlatformType
  30. #define LICENSEDPACK_PROCESS_LICENSETYPE LSKEYPACK_SEARCH_LICENSETYPE // ucLicenseType
  31. #define LICENSEDPACK_PROCESS_COP LSKEYPACK_SEARCH_COP // ucChannelOfPurchase
  32. #define LICENSEDPACK_PROCESS_BSERIALNUMBER LSKEYPACK_SEARCH_BSERIALNUMBER // szBeginSerialNumber
  33. #define LICENSEDPACK_PROCESS_TOTALLICENSES LSKEYPACK_SEARCH_TOTALLICENSES // dwTotalLicenseInKeyPack
  34. #define LICENSEDPACK_PROCESS_PRODUCTFLAGS LSKEYPACK_SEARCH_PRODUCTFLAGS // dwProductFlags
  35. #define LICENSEDPACK_PROCESS_COMPANYNAME LSKEYPACK_SEARCH_COMPANYNAME // szCompanyName
  36. #define LICENSEDPACK_PROCESS_EXPIREDATE LSKEYPACK_EXSEARCH_EXPIREDATE // dwExpirationDate
  37. //
  38. // Additional attribute for LicensedPack
  39. //
  40. #define LICENSEDPACK_PROCESS_ATTRIBUTE (LSKEYPACK_EXSEARCH_AVAILABLE << 2)
  41. #define LICENSEDPACK_PROCESS_KEYPACKSTATUS LSKEYPACK_EXSEARCH_KEYPACKSTATUS // ucKeyPackStatus
  42. #define LICENSEDPACK_PROCESS_AVAILABLE LSKEYPACK_EXSEARCH_AVAILABLE // dwNumberOfLicenses
  43. #define LICENSEDPACK_PROCESS_ACTIVATEDATE LSKEYPACK_EXSEARCH_ACTIVATEDATE // dwActivateDate
  44. #define LICENSEDPACK_PROCESS_EXPIREDATE LSKEYPACK_EXSEARCH_EXPIREDATE // dwExpirationDate
  45. #define LICENSEDPACK_PROCESS_DOMAINSID (LSKEYPACK_EXSEARCH_AVAILABLE << 3)
  46. #define LICENSEDPACK_PROCESS_LSSETUPID (LSKEYPACK_EXSEARCH_AVAILABLE << 4)
  47. #define LICENSEDPACK_PROCESS_DOMAINNAME (LSKEYPACK_EXSEARCH_AVAILABLE << 5)
  48. #define LICENSEDPACK_PROCESS_SERVERNAME (LSKEYPACK_EXSEARCH_AVAILABLE << 6)
  49. #define LICENSEDPACK_PROCESS_NEXTSERIALNUMBER (LSKEYPACK_EXSEARCH_AVAILABLE << 7)
  50. #define LICENSEDPACK_PROCESS_ENTRYSTATUS (LSKEYPACK_EXSEARCH_AVAILABLE << 8)
  51. #define LICENSEDPACK_ALLOCATE_LICENSE_UPDATE_FIELD \
  52. (LICENSEDPACK_PROCESS_AVAILABLE | LICENSEDPACK_PROCESS_NEXTSERIALNUMBER | LICENSEDPACK_PROCESS_MODIFYTIME)
  53. #define LICENSEDPACK_FIND_PRODUCT \
  54. (LSKEYPACK_SEARCH_KEYPACKID | LSKEYPACK_SEARCH_COMPANYNAME | \
  55. LSKEYPACK_SEARCH_PRODUCTID | LSKEYPACK_SEARCH_MAJORVERSION | \
  56. LSKEYPACK_SEARCH_MINORVERSION | LSKEYPACK_SEARCH_PLATFORMTYPE)
  57. #define LICENSEDPACK_FIND_LICENSEPACK \
  58. (LSKEYPACK_SEARCH_KEYPACKTYPE | LSKEYPACK_SEARCH_MAJORVERSION | \
  59. LSKEYPACK_SEARCH_MINORVERSION | LSKEYPACK_SEARCH_COMPANYNAME | \
  60. LSKEYPACK_SEARCH_PLATFORMTYPE)
  61. //
  62. // Licensed KeyPack Property Table Name
  63. //
  64. #define LICENSEDPACK_TABLE_NAME _TEXT("LicensedPack")
  65. //
  66. // Additional LicensedPack Column
  67. //
  68. #define LICENSEDPACK_COLUMN_KEYPACKID _TEXT("InternalKeyPackId")
  69. #define LICENSEDPACK_COLUMN_LASTMODIFYTIME _TEXT("LastModifyTime")
  70. //
  71. // KeyPack property as defined in backend doc.
  72. //
  73. #define LICENSEDPACK_COLUMN_LPID _TEXT("LPID") // license pack ID
  74. #define LICENSEDPACK_COLUMN_AGREEMENTTYPE _TEXT("AgreementType") // SELECT/MOLP/FREE
  75. #define LICENSEDPACK_COLUMN_COMPANYNAME _TEXT("CompanyName")
  76. #define LICENSEDPACK_COLUMN_PRODUCTID _TEXT("ProductID")
  77. #define LICENSEDPACK_COLUMN_MAJORVERSION _TEXT("ProductMajorVersion")
  78. #define LICENSEDPACK_COLUMN_MINORVERSION _TEXT("ProductMinorVersion")
  79. #define LICENSEDPACK_COLUMN_PLATFORMTYPE _TEXT("PlatformType")
  80. #define LICENSEDPACK_COLUMN_LICENSETYPE _TEXT("LicenseType")
  81. #define LICENSEDPACK_COLUMN_COP _TEXT("ChannelOfPurchase")
  82. #define LICENSEDPACK_COLUMN_BSERIALNUMBER _TEXT("BeginSerialNumber")
  83. #define LICENSEDPACK_COLUMN_TOTALLICENSES _TEXT("TotalLicenses")
  84. #define LICENSEDPACK_COLUMN_PRODUCTFLAGS _TEXT("ProductFlag")
  85. #define LICENSEDPACK_COLUMN_EXPIREDATE _TEXT("ExpirationDate")
  86. #define LICENSEDPACK_COLUMN_ATTRIBUTE _TEXT("KeyPackAttribute")
  87. #define LICENSEDPACK_COLUMN_KEYPACKSTATUS _TEXT("KeyPackStatus")
  88. #define LICENSEDPACK_COLUMN_AVAILABLE _TEXT("NumberLicenses")
  89. #define LICENSEDPACK_COLUMN_NEXTSERIALNUMBER _TEXT("NextSerialNumber")
  90. #define LICENSEDPACK_COLUMN_ACTIVATEDATE _TEXT("ActivationDate")
  91. #define LICENSEDPACK_COLUMN_EXPIREDATE _TEXT("ExpirationDate")
  92. #define LICENSEDPACK_COLUMN_DOMAINSETUPID _TEXT("TLSDomainSetupId")
  93. #define LICENSEDPACK_COLUMN_LSSETUPID _TEXT("TLSSetupId")
  94. #define LICENSEDPACK_COLUMN_DOMAINNAME _TEXT("DomainName")
  95. #define LICENSEDPACK_COLUMN_LSERVERNAME _TEXT("ServerName")
  96. #define LICENSEDPACK_COLUMN_ENTRYSTATUS _TEXT("EntryStatus")
  97. typedef struct __LicensePack : public TLSReplLicensePack
  98. {
  99. void
  100. Cleanup()
  101. {
  102. if(pbDomainSid != NULL)
  103. {
  104. FreeMemory(pbDomainSid);
  105. }
  106. }
  107. __LicensePack()
  108. {
  109. pbDomainSid = NULL;
  110. cbDomainSid = 0;
  111. }
  112. ~__LicensePack()
  113. {
  114. Cleanup();
  115. }
  116. __LicensePack&
  117. operator=(
  118. const TLSReplLicensePack& v
  119. )
  120. /*++
  121. ++*/
  122. {
  123. BOOL bSuccess;
  124. PBYTE pbOldData=pbDomainSid;
  125. DWORD cbOldData=cbDomainSid;
  126. *(TLSReplLicensePack *)this = v;
  127. pbDomainSid = pbOldData;
  128. cbDomainSid = cbOldData;
  129. bSuccess = TLSDBCopySid(
  130. (PSID)v.pbDomainSid,
  131. v.cbDomainSid,
  132. (PSID *)&pbDomainSid,
  133. &cbDomainSid
  134. );
  135. JB_ASSERT(bSuccess);
  136. return *this;
  137. }
  138. __LicensePack&
  139. operator=(const __LicensePack& v)
  140. /*++
  141. ++*/
  142. {
  143. BOOL bSuccess;
  144. PBYTE pbOldData=pbDomainSid;
  145. DWORD cbOldData=cbDomainSid;
  146. if(this == &v)
  147. return *this;
  148. *(TLSReplLicensePack *)this = *(TLSReplLicensePack *)&v;
  149. pbDomainSid = pbOldData;
  150. cbDomainSid = cbOldData;
  151. bSuccess = TLSDBCopySid(
  152. (PSID)v.pbDomainSid,
  153. v.cbDomainSid,
  154. (PSID *)&pbDomainSid,
  155. &cbDomainSid
  156. );
  157. JB_ASSERT(bSuccess);
  158. return *this;
  159. }
  160. } LICENSEPACK, *LPLICENSEPACK, *PLICENSEPACK;
  161. typedef LICENSEPACK TLSLICENSEPACK;
  162. typedef LPLICENSEPACK LPTLSLICENSEPACK;
  163. typedef PLICENSEPACK PTLSLICENSEPACK;
  164. ////////////////////////////////////////////////////////////////
  165. //
  166. // Primary Index on KeyPack ID (internal tracking number)
  167. //
  168. ////////////////////////////////////////////////////////////////
  169. //
  170. // LicensedPack_KeyPackId_idx
  171. //
  172. #define LICENSEDPACK_INDEX_INTERNALKEYPACKID_INDEXNAME \
  173. LICENSEDPACK_TABLE_NAME SEPERATOR LICENSEDPACK_COLUMN_KEYPACKID SEPERATOR INDEXNAME
  174. //
  175. // Index Key "+KeyPackId\0"
  176. //
  177. #define LICENSEDPACK_INDEX_INTERNALKEYPACKID_INDEXKEY \
  178. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_KEYPACKID INDEX_END_COLNAME
  179. typedef struct __LicensedPackIdxOnInternalKpId : public JBKeyBase {
  180. //
  181. // Primary Index on internal KeyPack tracking ID
  182. //
  183. DWORD dwKeyPackId;
  184. static LPCTSTR pszIndexName;
  185. static LPCTSTR pszIndexKey;
  186. //--------------------------------------------------------
  187. __LicensedPackIdxOnInternalKpId(
  188. const LICENSEPACK& v
  189. ) :
  190. JBKeyBase()
  191. /*++
  192. ++*/
  193. {
  194. *this = v;
  195. }
  196. //--------------------------------------------------------
  197. __LicensedPackIdxOnInternalKpId(
  198. const LICENSEPACK* v=NULL
  199. ) :
  200. JBKeyBase()
  201. /*++
  202. ++*/
  203. {
  204. if(v)
  205. {
  206. *this = *v;
  207. }
  208. }
  209. //--------------------------------------------------------
  210. __LicensedPackIdxOnInternalKpId&
  211. operator=(const LICENSEPACK& v)
  212. {
  213. dwKeyPackId = v.dwKeyPackId;
  214. SetEmptyValue(FALSE);
  215. return *this;
  216. }
  217. //--------------------------------------------------------
  218. LPCTSTR
  219. GetIndexName()
  220. {
  221. return pszIndexName;
  222. }
  223. //--------------------------------------------------------
  224. LPCTSTR
  225. GetIndexKey()
  226. {
  227. return pszIndexKey;
  228. }
  229. //--------------------------------------------------------
  230. DWORD
  231. GetNumKeyComponents() { return 1; }
  232. //--------------------------------------------------------
  233. BOOL
  234. GetSearchKey(
  235. DWORD dwComponentIndex,
  236. PVOID* pbData,
  237. unsigned long* cbData,
  238. JET_GRBIT* grbit,
  239. DWORD dwSearchParm
  240. )
  241. /*++
  242. ++*/
  243. {
  244. if(dwComponentIndex >= GetNumKeyComponents())
  245. {
  246. JB_ASSERT(FALSE);
  247. return FALSE;
  248. }
  249. *pbData = &(dwKeyPackId);
  250. *cbData = sizeof(dwKeyPackId);
  251. *grbit = JET_bitNewKey;
  252. return TRUE;
  253. }
  254. } TLSLicensedPackIdxInternalKpId;
  255. ////////////////////////////////////////////////////////////////
  256. //
  257. // Index on EntryLastModifyTime
  258. //
  259. //
  260. ////////////////////////////////////////////////////////////////
  261. //
  262. // LicensedPack_LastModifyTime_idx
  263. //
  264. #define LICENSEDPACK_INDEX_LASTMODIFYTIME_INDEXNAME \
  265. LICENSEDPACK_TABLE_NAME SEPERATOR LICENSEDPACK_COLUMN_LASTMODIFYTIME SEPERATOR INDEXNAME
  266. //
  267. // Index key "+LastModifyTime\0"
  268. //
  269. #define LICENSEDPACK_INDEX_LASTMODIFYTIME_INDEXKEY \
  270. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_LASTMODIFYTIME INDEX_END_COLNAME
  271. typedef struct __LicensedPackIdxOnModifyTime : public JBKeyBase {
  272. FILETIME ftLastModifyTime;
  273. static LPCTSTR pszIndexName;
  274. static LPCTSTR pszIndexKey;
  275. //--------------------------------------------------------
  276. __LicensedPackIdxOnModifyTime(
  277. const LICENSEPACK& v
  278. ) :
  279. JBKeyBase()
  280. /*++
  281. ++*/
  282. {
  283. *this = v;
  284. }
  285. //--------------------------------------------------------
  286. __LicensedPackIdxOnModifyTime(
  287. const LICENSEPACK* v=NULL
  288. ) :
  289. JBKeyBase()
  290. /*++
  291. ++*/
  292. {
  293. if(v)
  294. {
  295. *this = *v;
  296. }
  297. }
  298. //--------------------------------------------------------
  299. __LicensedPackIdxOnModifyTime&
  300. operator=(const LICENSEPACK& v)
  301. {
  302. ftLastModifyTime = v.ftLastModifyTime;
  303. SetEmptyValue(FALSE);
  304. return *this;
  305. }
  306. //--------------------------------------------------------
  307. LPCTSTR
  308. GetIndexName()
  309. {
  310. return pszIndexName;
  311. }
  312. //--------------------------------------------------------
  313. LPCTSTR
  314. GetIndexKey()
  315. {
  316. return pszIndexKey;
  317. }
  318. //--------------------------------------------------------
  319. DWORD
  320. GetNumKeyComponents() { return 1; }
  321. //--------------------------------------------------------
  322. BOOL
  323. GetSearchKey(
  324. DWORD dwComponentIndex,
  325. PVOID* pbData,
  326. unsigned long* cbData,
  327. JET_GRBIT* grbit,
  328. DWORD dwSearchParm
  329. )
  330. /*++
  331. ++*/
  332. {
  333. if(dwComponentIndex >= GetNumKeyComponents())
  334. {
  335. JB_ASSERT(FALSE);
  336. return FALSE;
  337. }
  338. *pbData = &(ftLastModifyTime);
  339. *cbData = sizeof(ftLastModifyTime);
  340. *grbit = JET_bitNewKey;
  341. return TRUE;
  342. }
  343. } TLSLicensedPackIdxLastModifyTime;
  344. ////////////////////////////////////////////////////////////////
  345. //
  346. // Index on Company name
  347. //
  348. //
  349. ////////////////////////////////////////////////////////////////
  350. //
  351. // KeyPack_CompanyName_idx
  352. //
  353. #define LICENSEDPACK_INDEX_COMPANYNAME_INDEXNAME \
  354. LICENSEDPACK_TABLE_NAME SEPERATOR LICENSEDPACK_COLUMN_COMPANYNAME SEPERATOR INDEXNAME
  355. //
  356. // Index on key "+CompanyName\0"
  357. //
  358. #define LICENSEDPACK_INDEX_COMPANYNAME_INDEXKEY \
  359. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_COMPANYNAME INDEX_END_COLNAME
  360. typedef struct __LicensedPackIdxOnCompanyName : public JBKeyBase {
  361. TCHAR szCompanyName[ MAX_JETBLUE_TEXT_LENGTH + 1 ];
  362. static LPCTSTR pszIndexName;
  363. static LPCTSTR pszIndexKey;
  364. //-------------------------------------------------
  365. __LicensedPackIdxOnCompanyName(
  366. const LICENSEPACK& v
  367. ) : JBKeyBase()
  368. /*++
  369. ++*/
  370. {
  371. *this = v;
  372. }
  373. //-------------------------------------------------
  374. __LicensedPackIdxOnCompanyName(
  375. const LICENSEPACK* v=NULL
  376. ) : JBKeyBase()
  377. /*++
  378. ++*/
  379. {
  380. if(v)
  381. {
  382. *this = *v;
  383. }
  384. }
  385. //-------------------------------------------------
  386. __LicensedPackIdxOnCompanyName&
  387. operator=(const LICENSEPACK& v) {
  388. SetEmptyValue(FALSE);
  389. _tcscpy(szCompanyName, v.szCompanyName);
  390. return *this;
  391. }
  392. //--------------------------------------------------------
  393. LPCTSTR
  394. GetIndexName()
  395. {
  396. return pszIndexName;
  397. }
  398. //--------------------------------------------------------
  399. LPCTSTR
  400. GetIndexKey()
  401. {
  402. return pszIndexKey;
  403. }
  404. //--------------------------------------------------------
  405. DWORD
  406. GetNumKeyComponents() { return 1; }
  407. //--------------------------------------------------------
  408. BOOL
  409. GetSearchKey(
  410. DWORD dwComponentIndex,
  411. PVOID* pbData,
  412. unsigned long* cbData,
  413. JET_GRBIT* grbit,
  414. DWORD dwSearchParm
  415. )
  416. /*++
  417. ++*/
  418. {
  419. if(dwComponentIndex >= GetNumKeyComponents())
  420. {
  421. JB_ASSERT(FALSE);
  422. return FALSE;
  423. }
  424. *pbData = &(szCompanyName[0]);
  425. *cbData = _tcslen(szCompanyName) * sizeof(TCHAR);
  426. *grbit = JET_bitNewKey;
  427. return TRUE;
  428. }
  429. } TLSLicensedPackIdxCompany;
  430. ////////////////////////////////////////////////////////////////
  431. //
  432. // Index on Product ID
  433. //
  434. //
  435. ////////////////////////////////////////////////////////////////
  436. //
  437. // LicensedPack_ProductId_idx
  438. //
  439. #define LICENSEDPACK_INDEX_PRODUCTID_INDEXNAME \
  440. LICENSEDPACK_TABLE_NAME SEPERATOR LICENSEDPACK_COLUMN_PRODUCTID SEPERATOR INDEXNAME
  441. //
  442. // Index on key "+ProductId\0"
  443. //
  444. #define LICENSEDPACK_INDEX_PRODUCTID_INDEXKEY \
  445. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_PRODUCTID INDEX_END_COLNAME
  446. typedef struct __LicensedPackIdxOnProductId : public JBKeyBase {
  447. TCHAR szProductId[ MAX_JETBLUE_TEXT_LENGTH + 1 ];
  448. static LPCTSTR pszIndexName;
  449. static LPCTSTR pszIndexKey;
  450. //--------------------------------------------------------
  451. __LicensedPackIdxOnProductId(
  452. const LICENSEPACK& v
  453. ) :
  454. JBKeyBase()
  455. /*++
  456. ++*/
  457. {
  458. *this = v;
  459. }
  460. //--------------------------------------------------------
  461. __LicensedPackIdxOnProductId(
  462. const LICENSEPACK* v=NULL
  463. ) :
  464. JBKeyBase()
  465. /*++
  466. ++*/
  467. {
  468. if(v)
  469. {
  470. *this = *v;
  471. }
  472. }
  473. //--------------------------------------------------------
  474. __LicensedPackIdxOnProductId&
  475. operator=(const LICENSEPACK& v) {
  476. SetEmptyValue(FALSE);
  477. _tcscpy(szProductId, v.szProductId);
  478. return *this;
  479. }
  480. //--------------------------------------------------------
  481. LPCTSTR
  482. GetIndexName()
  483. {
  484. return pszIndexName;
  485. }
  486. //--------------------------------------------------------
  487. LPCTSTR
  488. GetIndexKey()
  489. {
  490. return pszIndexKey;
  491. }
  492. //--------------------------------------------------------
  493. DWORD
  494. GetNumKeyComponents() { return 1; }
  495. //--------------------------------------------------------
  496. BOOL
  497. GetSearchKey(
  498. DWORD dwComponentIndex,
  499. PVOID* pbData,
  500. unsigned long* cbData,
  501. JET_GRBIT* grbit,
  502. DWORD dwSearchParm
  503. )
  504. /*++
  505. ++*/
  506. {
  507. if(dwComponentIndex >= GetNumKeyComponents())
  508. {
  509. JB_ASSERT(FALSE);
  510. return FALSE;
  511. }
  512. *pbData = &(szProductId[0]);
  513. *cbData = _tcslen(szProductId) * sizeof(TCHAR);
  514. *grbit = JET_bitNewKey;
  515. return TRUE;
  516. }
  517. } TLSLicensedPackIdxProductId;
  518. ////////////////////////////////////////////////////////////////
  519. //
  520. // Index on KeyPack ID
  521. //
  522. //
  523. ////////////////////////////////////////////////////////////////
  524. //
  525. // KeyPack_LPID_idx
  526. //
  527. #define LICENSEDPACK_INDEX_KEYPACKID_INDEXNAME \
  528. LICENSEDPACK_TABLE_NAME SEPERATOR LICENSEDPACK_COLUMN_LPID SEPERATOR INDEXNAME
  529. //
  530. // Index on key "+lpid\0"
  531. //
  532. #define LICENSEDPACK_INDEX_KEYPACKID_INDEXKEY \
  533. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_LPID INDEX_END_COLNAME
  534. typedef struct __LicensedPackIdxOnKeyPackId : public JBKeyBase {
  535. TCHAR szKeyPackId[ MAX_JETBLUE_TEXT_LENGTH + 1 ];
  536. static LPCTSTR pszIndexName;
  537. static LPCTSTR pszIndexKey;
  538. //----------------------------------------------
  539. __LicensedPackIdxOnKeyPackId(
  540. const LICENSEPACK& v
  541. ) :
  542. JBKeyBase()
  543. /*++
  544. ++*/
  545. {
  546. *this = v;
  547. }
  548. //----------------------------------------------
  549. __LicensedPackIdxOnKeyPackId(
  550. const LICENSEPACK* v=NULL
  551. ) :
  552. JBKeyBase()
  553. /*++
  554. ++*/
  555. {
  556. if(v)
  557. {
  558. *this = *v;
  559. }
  560. }
  561. //----------------------------------------------
  562. __LicensedPackIdxOnKeyPackId&
  563. operator=(const LICENSEPACK& v) {
  564. SetEmptyValue(FALSE);
  565. _tcscpy(szKeyPackId, v.szKeyPackId);
  566. return *this;
  567. }
  568. //--------------------------------------------------------
  569. LPCTSTR
  570. GetIndexName()
  571. {
  572. return pszIndexName;
  573. }
  574. //--------------------------------------------------------
  575. LPCTSTR
  576. GetIndexKey()
  577. {
  578. return pszIndexKey;
  579. }
  580. //--------------------------------------------------------
  581. DWORD
  582. GetNumKeyComponents() { return 1; }
  583. //--------------------------------------------------------
  584. BOOL
  585. GetSearchKey(
  586. DWORD dwComponentIndex,
  587. PVOID* pbData,
  588. unsigned long* cbData,
  589. JET_GRBIT* grbit,
  590. DWORD dwSearchParm
  591. )
  592. /*++
  593. ++*/
  594. {
  595. if(dwComponentIndex >= GetNumKeyComponents())
  596. {
  597. JB_ASSERT(FALSE);
  598. return FALSE;
  599. }
  600. *pbData = &(szKeyPackId[0]);
  601. *cbData = _tcslen(szKeyPackId) * sizeof(TCHAR);
  602. *grbit = JET_bitNewKey;
  603. return TRUE;
  604. }
  605. } TLSLicensedPackIdxKeyPackId;
  606. //
  607. ////////////////////////////////////////////////////////////////
  608. //
  609. ////////////////////////////////////////////////////////////////
  610. //
  611. // Index for searching Installed License Pack
  612. // Max. 255 bytes per key so must looping
  613. //
  614. ////////////////////////////////////////////////////////////////
  615. //
  616. // Index name KeyPack_InstalledProduct_idx
  617. //
  618. #define LICENSEDPACK_INDEX_INSTALLEDPRODUCT_INDEXNAME \
  619. LICENSEDPACK_TABLE_NAME SEPERATOR _TEXT("InstalledProduct") SEPERATOR INDEXNAME
  620. //
  621. // Number of Component in this key
  622. #define LICENSEDPACK_INSTALLEDPRODUCT_KEY_COMPONENTS 6
  623. //
  624. //
  625. // Index Key "+LPID\0+MajorVersion\0+MinorVersion\0+PlatformType\0+CompanyName\0+ProductId\0"
  626. //
  627. #define LICENSEDPACK_INDEX_INSTALLEDPRODUCT_INDEXKEY \
  628. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_LPID INDEX_END_COLNAME \
  629. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_MAJORVERSION INDEX_END_COLNAME \
  630. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_MINORVERSION INDEX_END_COLNAME \
  631. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_PLATFORMTYPE INDEX_END_COLNAME \
  632. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_COMPANYNAME INDEX_END_COLNAME \
  633. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_PRODUCTID INDEX_END_COLNAME
  634. typedef struct __LicensedPackIdxOnInstalledProduct : public JBKeyBase {
  635. //
  636. // Index for searching duplicate KeyPack
  637. //
  638. //
  639. // Adding or removing member must modify GetNumKeyComponents()
  640. //
  641. TCHAR szKeyPackId[LSERVER_MAX_STRING_SIZE + 1];
  642. WORD wMajorVersion;
  643. WORD wMinorVersion;
  644. DWORD dwPlatformType;
  645. TCHAR szCompanyName[LSERVER_MAX_STRING_SIZE + 1];
  646. TCHAR szProductId[LSERVER_MAX_STRING_SIZE + 1];
  647. static LPCTSTR pszIndexName;
  648. static LPCTSTR pszIndexKey;
  649. //---------------------------------------------------------------
  650. __LicensedPackIdxOnInstalledProduct(
  651. const LICENSEPACK& v
  652. ) :
  653. JBKeyBase()
  654. /*++
  655. ++*/
  656. {
  657. *this = v;
  658. }
  659. //---------------------------------------------------------------
  660. __LicensedPackIdxOnInstalledProduct(
  661. const LICENSEPACK* v=NULL
  662. ) :
  663. JBKeyBase()
  664. /*++
  665. ++*/
  666. {
  667. if(v)
  668. {
  669. *this = *v;
  670. }
  671. }
  672. //---------------------------------------------------------------
  673. __LicensedPackIdxOnInstalledProduct&
  674. operator=(const LICENSEPACK& v) {
  675. _tcscpy(szKeyPackId, v.szKeyPackId);
  676. _tcscpy(szCompanyName, v.szCompanyName);
  677. _tcscpy(szProductId, v.szProductId);
  678. wMajorVersion = v.wMajorVersion;
  679. wMinorVersion = v.wMinorVersion;
  680. dwPlatformType = v.dwPlatformType;
  681. SetEmptyValue(FALSE);
  682. return *this;
  683. }
  684. //--------------------------------------------------------
  685. LPCTSTR
  686. GetIndexName()
  687. {
  688. return pszIndexName;
  689. }
  690. //--------------------------------------------------------
  691. LPCTSTR
  692. GetIndexKey()
  693. {
  694. return pszIndexKey;
  695. }
  696. //--------------------------------------------------------
  697. DWORD
  698. GetNumKeyComponents() {
  699. return LICENSEDPACK_INSTALLEDPRODUCT_KEY_COMPONENTS;
  700. }
  701. //--------------------------------------------------------
  702. BOOL
  703. GetSearchKey(
  704. DWORD dwComponentIndex,
  705. PVOID* pbData,
  706. unsigned long* cbData,
  707. JET_GRBIT* grbit,
  708. DWORD dwSearchParm
  709. )
  710. /*++
  711. ++*/
  712. {
  713. BOOL retCode=TRUE;
  714. *cbData = 0;
  715. *grbit = 0;
  716. if(dwComponentIndex >= GetNumKeyComponents())
  717. {
  718. JB_ASSERT(FALSE);
  719. return FALSE;
  720. }
  721. switch(dwComponentIndex)
  722. {
  723. case 0:
  724. //
  725. // hopefully, this will reduce the number of record needed to
  726. // loop thru.
  727. //
  728. *pbData = &(szKeyPackId[0]);
  729. *cbData = _tcslen(szKeyPackId) * sizeof(TCHAR);
  730. *grbit = JET_bitNewKey;
  731. break;
  732. case 1:
  733. *pbData = &(wMajorVersion);
  734. *cbData = sizeof(wMajorVersion);
  735. break;
  736. case 2:
  737. *pbData = &(wMinorVersion);
  738. *cbData = sizeof(wMinorVersion);
  739. break;
  740. case 3:
  741. *pbData = &(dwPlatformType);
  742. *cbData = sizeof(dwPlatformType);
  743. break;
  744. case 4:
  745. *pbData = &(szCompanyName[0]);
  746. *cbData = _tcslen(szCompanyName) * sizeof(TCHAR);
  747. break;
  748. case 5:
  749. *pbData = &(szProductId[0]);
  750. *cbData = _tcslen(szProductId) * sizeof(TCHAR);
  751. break;
  752. default:
  753. JB_ASSERT(FALSE);
  754. retCode = FALSE;
  755. break;
  756. }
  757. return retCode;
  758. }
  759. } TLSLicensedPackIdxInstalledProduct;
  760. ////////////////////////////////////////////////////////////////
  761. //
  762. // Index for Allocated license
  763. //
  764. ////////////////////////////////////////////////////////////////
  765. //
  766. // Index name for allocating license - KeyPack_AllocateLicense_idx
  767. //
  768. #define LICENSEDPACK_INDEX_ALLOCATELICENSE_INDEXNAME \
  769. LICENSEDPACK_TABLE_NAME SEPERATOR _TEXT("AllocateLicense") SEPERATOR INDEXNAME
  770. #define LICENSEDPACK_ALLOCATELICENSE_KEY_COMPONENTS 6
  771. //
  772. // Index key for allocating license
  773. // "+KeyPackType\0+ProductMajorVersion\0+ProductMinorVersion\0+PlatformType+CompanyName\0+ProductID\0"
  774. //
  775. #define LICENSEDPACK_INDEX_ALLOCATELICENSE_INDEXKEY \
  776. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_AGREEMENTTYPE INDEX_END_COLNAME \
  777. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_MAJORVERSION INDEX_END_COLNAME \
  778. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_MINORVERSION INDEX_END_COLNAME \
  779. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_PLATFORMTYPE INDEX_END_COLNAME \
  780. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_COMPANYNAME INDEX_END_COLNAME \
  781. INDEX_SORT_ASCENDING LICENSEDPACK_COLUMN_PRODUCTID INDEX_END_COLNAME
  782. typedef struct __LicensedPackIdxOnAllocLicense : public JBKeyBase {
  783. //
  784. // Index for allocating licenses
  785. //
  786. UCHAR ucAgreementType;
  787. WORD wMajorVersion;
  788. WORD wMinorVersion;
  789. DWORD dwPlatformType;
  790. TCHAR szCompanyName[LSERVER_MAX_STRING_SIZE + 1];
  791. TCHAR szProductId[LSERVER_MAX_STRING_SIZE + 1];
  792. static LPCTSTR pszIndexName;
  793. static LPCTSTR pszIndexKey;
  794. //------------------------------------------------------
  795. __LicensedPackIdxOnAllocLicense(
  796. const LICENSEPACK* v=NULL
  797. ) : JBKeyBase()
  798. /*++
  799. ++*/
  800. {
  801. if(v)
  802. {
  803. *this = *v;
  804. }
  805. }
  806. //------------------------------------------------------
  807. __LicensedPackIdxOnAllocLicense(
  808. const LICENSEPACK& v
  809. ) :
  810. JBKeyBase()
  811. /*++
  812. ++*/
  813. {
  814. *this = v;
  815. }
  816. __LicensedPackIdxOnAllocLicense&
  817. operator=(const LICENSEPACK& v) {
  818. ucAgreementType = v.ucAgreementType;
  819. _tcscpy(szCompanyName, v.szCompanyName);
  820. _tcscpy(szProductId, v.szProductId);
  821. wMajorVersion = v.wMajorVersion;
  822. wMinorVersion = v.wMinorVersion;
  823. dwPlatformType = v.dwPlatformType;
  824. SetEmptyValue(FALSE);
  825. return *this;
  826. }
  827. //--------------------------------------------------------
  828. LPCTSTR
  829. GetIndexName()
  830. {
  831. return pszIndexName;
  832. }
  833. //--------------------------------------------------------
  834. LPCTSTR
  835. GetIndexKey()
  836. {
  837. return pszIndexKey;
  838. }
  839. //--------------------------------------------------------
  840. DWORD
  841. GetNumKeyComponents() {
  842. return LICENSEDPACK_ALLOCATELICENSE_KEY_COMPONENTS;
  843. }
  844. //--------------------------------------------------------------
  845. inline BOOL
  846. GetSearchKey(
  847. DWORD dwComponentIndex,
  848. PVOID* pbData,
  849. unsigned long* cbData,
  850. JET_GRBIT* grbit,
  851. DWORD dwSearchParm
  852. )
  853. /*
  854. */
  855. {
  856. BOOL retCode=TRUE;
  857. if(dwComponentIndex >= GetNumKeyComponents())
  858. {
  859. JB_ASSERT(FALSE);
  860. return FALSE;
  861. }
  862. *cbData = 0;
  863. *grbit = 0;
  864. switch(dwComponentIndex)
  865. {
  866. case 0:
  867. *pbData = &(ucAgreementType);
  868. *cbData = sizeof(ucAgreementType);
  869. *grbit = JET_bitNewKey;
  870. break;
  871. case 1:
  872. *pbData = &(wMajorVersion);
  873. *cbData = sizeof(wMajorVersion);
  874. break;
  875. case 2:
  876. *pbData = &(wMinorVersion);
  877. *cbData = sizeof(wMinorVersion);
  878. break;
  879. case 3:
  880. *pbData = &(dwPlatformType);
  881. *cbData = sizeof(dwPlatformType);
  882. break;
  883. case 4:
  884. *pbData = &(szCompanyName[0]);
  885. *cbData = _tcslen(szCompanyName) * sizeof(TCHAR);
  886. break;
  887. case 5:
  888. *pbData = &(szProductId[0]);
  889. *cbData = _tcslen(szProductId) * sizeof(TCHAR);
  890. break;
  891. default:
  892. JB_ASSERT(FALSE);
  893. retCode = FALSE;
  894. break;
  895. }
  896. return retCode;
  897. }
  898. } TLSLicensedPackIdxAllocateLicense;
  899. //------------------------------------------------------------
  900. // -----------------------------------------------------------
  901. // LicensedPack Table Structure
  902. // -----------------------------------------------------------
  903. class LicPackTable : public TLSTable<LICENSEPACK> {
  904. private:
  905. static LPCTSTR pszTableName;
  906. BOOL
  907. ProcessSingleColumn(
  908. BOOL bFetch,
  909. TLSColumnBase& column,
  910. DWORD offset,
  911. PVOID pbData,
  912. DWORD cbData,
  913. PDWORD pcbDataReturn,
  914. LPCTSTR szColumnName
  915. );
  916. BOOL
  917. ProcessRecord(
  918. LICENSEPACK* v,
  919. BOOL bFetch, // TRUE - fetch, FALSE insert
  920. DWORD dwParam,
  921. BOOL bUpdate
  922. );
  923. public:
  924. TLSColumnUchar ucEntryStatus;
  925. //
  926. // Additional License Pack Property.
  927. //
  928. TLSColumnDword dwKeyPackId;
  929. TLSColumnFileTime ftLastModifyTime;
  930. TLSColumnDword dwAttribute;
  931. TLSColumnDword dwNextSerialNumber;
  932. TLSColumnDword dwActivateDate;
  933. TLSColumnDword dwExpirationDate;
  934. TLSColumnDword dwNumberOfLicenses;
  935. TLSColumnUchar ucKeyPackStatus;
  936. TLSColumnBinary pbDomainSid;
  937. TLSColumnText szInstallId;
  938. TLSColumnText szDomainName;
  939. TLSColumnText szTlsServerName;
  940. //
  941. // Standard License Pack Property
  942. //
  943. TLSColumnText szKeyPackId;
  944. TLSColumnUchar ucAgreementType;
  945. TLSColumnText szCompanyName;
  946. TLSColumnText szProductId;
  947. TLSColumnShort wMajorVersion;
  948. TLSColumnShort wMinorVersion;
  949. TLSColumnDword dwPlatformType;
  950. TLSColumnUchar ucLicenseType;
  951. TLSColumnUchar ucChannelOfPurchase;
  952. TLSColumnText szBeginSerialNumber;
  953. TLSColumnDword dwTotalLicenseInKeyPack;
  954. TLSColumnDword dwProductFlags;
  955. //-----------------------------------------------------
  956. virtual LPCTSTR
  957. GetTableName()
  958. {
  959. return pszTableName;
  960. }
  961. //-----------------------------------------------------
  962. LicPackTable(
  963. JBDatabase& database
  964. ) :
  965. TLSTable<LICENSEPACK> (database)
  966. /*
  967. */
  968. {
  969. }
  970. //-----------------------------------------------------
  971. virtual BOOL
  972. ResolveToTableColumn();
  973. //-----------------------------------------------------
  974. virtual BOOL
  975. FetchRecord(
  976. LICENSEPACK& kp,
  977. DWORD dwParam=PROCESS_ALL_COLUMNS
  978. )
  979. /*
  980. */
  981. {
  982. if(IsValid() == FALSE)
  983. {
  984. DebugOutput(
  985. _TEXT("Table %s is not valid...\n"),
  986. GetTableName()
  987. );
  988. JB_ASSERT(FALSE);
  989. SetLastJetError(JET_errInvalidParameter);
  990. return FALSE;
  991. }
  992. //CCriticalSectionLocker Lock(GetTableLock());
  993. return ProcessRecord(&kp, TRUE, dwParam, FALSE);
  994. }
  995. //-----------------------------------------------------
  996. virtual BOOL
  997. InsertRecord(
  998. LICENSEPACK& kp,
  999. DWORD dwParam=PROCESS_ALL_COLUMNS
  1000. )
  1001. /*
  1002. */
  1003. {
  1004. if(IsValid() == FALSE)
  1005. {
  1006. DebugOutput(
  1007. _TEXT("Table %s is not valid...\n"),
  1008. GetTableName()
  1009. );
  1010. JB_ASSERT(FALSE);
  1011. SetLastJetError(JET_errInvalidParameter);
  1012. return FALSE;
  1013. }
  1014. //CCriticalSectionLocker Lock(GetTableLock());
  1015. return ProcessRecord(&kp, FALSE, dwParam, FALSE);
  1016. }
  1017. //-------------------------------------------------------
  1018. virtual BOOL
  1019. UpdateRecord(
  1020. LICENSEPACK& kp,
  1021. DWORD dwParam=PROCESS_ALL_COLUMNS
  1022. )
  1023. /*
  1024. */
  1025. {
  1026. if(IsValid() == FALSE)
  1027. {
  1028. DebugOutput(
  1029. _TEXT("Table %s is not valid...\n"),
  1030. GetTableName()
  1031. );
  1032. JB_ASSERT(FALSE);
  1033. SetLastJetError(JET_errInvalidParameter);
  1034. return FALSE;
  1035. }
  1036. //CCriticalSectionLocker Lock(GetTableLock());
  1037. return ProcessRecord(&kp, FALSE, dwParam, TRUE);
  1038. }
  1039. //-------------------------------------------------------
  1040. virtual BOOL
  1041. Initialize()
  1042. {
  1043. return TRUE;
  1044. }
  1045. //-------------------------------------------------------
  1046. virtual JBKeyBase*
  1047. EnumerationIndex(
  1048. IN BOOL bMatchAll,
  1049. IN DWORD dwParam,
  1050. IN LICENSEPACK* kp,
  1051. IN OUT BOOL* bCompareKey
  1052. );
  1053. virtual BOOL
  1054. EqualValue(
  1055. LICENSEPACK& s1,
  1056. LICENSEPACK& s2,
  1057. BOOL bMatchAll,
  1058. DWORD dwParam
  1059. );
  1060. };
  1061. #endif