00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "precomp.h"
00028 #include "CCPrintLicenseInfo.h"
00029
00030 #include "CCPrintRegistry.h"
00031
00033 #define REG_LICENSE_BASE_NAME _T("License")
00034
00036 #define REG_LICENSE_TYPE_NAME _T("Type")
00038 #define REG_LICENSE_COMMERCIAL_NAME _T("Commercial")
00040 #define REG_LICENSE_MODIFICATION_NAME _T("Modification")
00042 #define REG_LICENSE_JURISDICTION_NAME _T("Jurisdiction")
00044 #define REG_LICENSE_SAMPLING_NAME _T("Sampling")
00046 #define REG_LICENSE_NAME_NAME _T("Name")
00048 #define REG_LICENSE_URI_NAME _T("URI")
00049
00051 #define REG_LOCATION_BASE_NAME _T("Location")
00052
00054 #define REG_LOCATION_FIRSTPAGE_NAME _T("FirstPage")
00056 #define REG_LOCATION_FIRSTPAGE_X_NAME _T("FirstPageX")
00058 #define REG_LOCATION_FIRSTPAGE_Y_NAME _T("FirstPageY")
00060 #define REG_LOCATION_OTHERPAGES_NAME _T("OtherPages")
00062 #define REG_LOCATION_OTHERPAGES_X_NAME _T("OtherPagesX")
00064 #define REG_LOCATION_OTHERPAGES_Y_NAME _T("OtherPagesY")
00065
00070 void CCPrintLicenseInfo::ReadFromRegistry(HANDLE hPrinter, LicenseInfo& info)
00071 {
00072
00073 info.Clear();
00074
00075
00076 info.m_eLicense = (LicenseType)CCPrintRegistry::GetRegistryInt(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_TYPE_NAME, LTUnknown);
00077 info.m_bCommercialUse = CCPrintRegistry::GetRegistryBool(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_COMMERCIAL_NAME, false);
00078 info.m_eModification = (ModificationType)CCPrintRegistry::GetRegistryInt(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_MODIFICATION_NAME, MTUnknown);
00079 info.SetJurisdiction(CCPrintRegistry::GetRegistryString(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_JURISDICTION_NAME, _T("")).c_str());
00080 info.m_cJurisdiction[MAX_JURISDICTION - 1] = '\0';
00081 info.m_eSampling = (SamplingType)CCPrintRegistry::GetRegistryInt(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_SAMPLING_NAME, STUnknown);
00082 info.SetName(CCPrintRegistry::GetRegistryString(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_NAME_NAME, _T("")).c_str());
00083 info.SetURI(CCPrintRegistry::GetRegistryString(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_URI_NAME, _T("")).c_str());
00084 }
00085
00090 bool CCPrintLicenseInfo::WriteToRegistry(HANDLE hPrinter, const LicenseInfo& info)
00091 {
00092
00093 bool bRet = true;
00094 bRet &= CCPrintRegistry::SetRegistryInt(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_TYPE_NAME, (int)info.m_eLicense);
00095 bRet &= CCPrintRegistry::SetRegistryBool(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_COMMERCIAL_NAME, info.m_bCommercialUse);
00096 bRet &= CCPrintRegistry::SetRegistryInt(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_MODIFICATION_NAME, (int)info.m_eModification);
00097 bRet &= CCPrintRegistry::SetRegistryString(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_JURISDICTION_NAME, info.m_cJurisdiction);
00098 bRet &= CCPrintRegistry::SetRegistryInt(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_SAMPLING_NAME, (int)info.m_eSampling);
00099 bRet &= CCPrintRegistry::SetRegistryString(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_NAME_NAME, info.m_cName);
00100 bRet &= CCPrintRegistry::SetRegistryString(hPrinter, REG_LICENSE_BASE_NAME REG_LICENSE_URI_NAME, info.m_cURI);
00101 return bRet;
00102 }
00103
00108 void CCPrintLicenseInfo::ReadFromRegistry(HANDLE hPrinter, LicenseLocationInfo& info)
00109 {
00110
00111 info.Clear();
00112
00113 info.eFirstPage = (LicenseLocation)CCPrintRegistry::GetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_FIRSTPAGE_NAME, LLNone);
00114 if (info.eFirstPage == LLUserDefined)
00115 {
00116
00117 info.ptFirstPage.x = CCPrintRegistry::GetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_FIRSTPAGE_X_NAME, 0);
00118 info.ptFirstPage.y = CCPrintRegistry::GetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_FIRSTPAGE_Y_NAME, 0);
00119 }
00120 else
00121 {
00122
00123 info.ptFirstPage.x = 50;
00124 info.ptFirstPage.y = 0;
00125 }
00126
00127 info.eOtherPages = (LicenseLocation)CCPrintRegistry::GetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_OTHERPAGES_NAME, LLNone);
00128 if (info.eOtherPages == LLUserDefined)
00129 {
00130
00131 info.ptOtherPages.x = CCPrintRegistry::GetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_OTHERPAGES_X_NAME, 0);
00132 info.ptOtherPages.y = CCPrintRegistry::GetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_OTHERPAGES_Y_NAME, 0);
00133 }
00134 else
00135 {
00136
00137 info.ptFirstPage.x = 50;
00138 info.ptFirstPage.y = 0;
00139 }
00140 }
00141
00146 bool CCPrintLicenseInfo::WriteToRegistry(HANDLE hPrinter, const LicenseLocationInfo& info)
00147 {
00148
00149 bool bRet = true;
00150 bRet &= CCPrintRegistry::SetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_FIRSTPAGE_NAME, (int)info.eFirstPage);
00151 if (info.eFirstPage == LLUserDefined)
00152 {
00153
00154 bRet &= CCPrintRegistry::SetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_FIRSTPAGE_X_NAME, (int)info.ptFirstPage.x);
00155 bRet &= CCPrintRegistry::SetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_FIRSTPAGE_Y_NAME, (int)info.ptFirstPage.y);
00156 }
00157
00158 bRet &= CCPrintRegistry::SetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_OTHERPAGES_NAME, (int)info.eOtherPages);
00159 if (info.eOtherPages == LLUserDefined)
00160 {
00161
00162 bRet &= CCPrintRegistry::SetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_OTHERPAGES_X_NAME, (int)info.ptOtherPages.x);
00163 bRet &= CCPrintRegistry::SetRegistryInt(hPrinter, REG_LOCATION_BASE_NAME REG_LOCATION_OTHERPAGES_Y_NAME, (int)info.ptOtherPages.y);
00164 }
00165 return bRet;
00166 }