XN_C_API XnStatus xnUnregisterGlobalLicense(XnLicense* pLicense) { XnStatus nRetVal = XN_STATUS_OK; XnLicensesXml licenses; nRetVal = loadLicensesFile(licenses); XN_IS_STATUS_OK(nRetVal); // check if it's there XnBool bFound = FALSE; for (XnLicenseXmlList::ConstIterator it = licenses.begin(); it != licenses.end(); ++it) { const XnLicenseXml& license = *it; if (strcmp(license.strVendor, pLicense->strVendor) == 0 && strcmp(license.strKey, pLicense->strKey) == 0) { nRetVal = licenses.Remove(it); XN_IS_STATUS_OK(nRetVal); nRetVal = saveLicensesFile(licenses); XN_IS_STATUS_OK(nRetVal); bFound = TRUE; break; } } if (!bFound) { return (XN_STATUS_NO_MATCH); } return (XN_STATUS_OK); }
XN_C_API XnStatus xnRegisterGlobalLicense(XnLicense* pLicense) { XnStatus nRetVal = XN_STATUS_OK; XnLicensesXml licenses; nRetVal = loadLicensesFile(licenses); XN_IS_STATUS_OK(nRetVal); // check if it's already there XnBool bFound = FALSE; for (XnLicensesXml::ConstIterator it = licenses.Begin(); it != licenses.End(); ++it) { const XnLicenseXml& license = *it; if (strcmp(license.strVendor, pLicense->strVendor) == 0 && strcmp(license.strKey, pLicense->strKey) == 0) { bFound = TRUE; break; } } if (!bFound) { XnLicenseXml license(pLicense); nRetVal = licenses.AddLast(license); XN_IS_STATUS_OK(nRetVal); nRetVal = saveLicensesFile(licenses); XN_IS_STATUS_OK(nRetVal); } return (XN_STATUS_OK); }
XnStatus xnLoadGlobalLicenses(XnContext* pContext) { XnStatus nRetVal = XN_STATUS_OK; TiXmlDocument doc; nRetVal = loadLicensesFile(doc); XN_IS_STATUS_OK(nRetVal); nRetVal = xnLoadLicensesFromElement(pContext, doc.RootElement()); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus loadLicensesFile(XnLicensesXml& licenses) { XnStatus nRetVal = XN_STATUS_OK; TiXmlDocument doc; nRetVal = loadLicensesFile(doc); XN_IS_STATUS_OK(nRetVal); nRetVal = licenses.FromElement(doc.RootElement()); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XN_C_API XnStatus xnPrintRegisteredLicenses() { XnStatus nRetVal = XN_STATUS_OK; XnLicensesXml licenses; nRetVal = loadLicensesFile(licenses); XN_IS_STATUS_OK(nRetVal); printf("%-20s%-20s\n", "VENDOR", "KEY"); printf("%-20s%-20s\n", "======", "==="); for (XnLicenseXmlList::ConstIterator it = licenses.begin(); it != licenses.end(); ++it) { const XnLicenseXml& license = *it; printf("%-20s%-20s\n", license.strVendor, license.strKey); } return (XN_STATUS_OK); }