test: profile.h Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# profile.h

Go to the documentation of this file.

    00001 /******************************************************************************
    00002
    00003   Header File:  ICC Profile.H
    00004
    00005   This defines the C++ class we encapsulate the profile in.  It also defines
    00006   the base class for device enumeration.  All activity related to the profile,
    00007   including installations, associations, and so forth, is encapsulated in the
    00008   CProfile class.  The UI classes themselves never call an ICM API, but are
    00009   instead concerned with simply handling the interface.
    00010
    00011   Copyright (c) 1996 by Microsoft Corporation
    00012
    00013   A Pretty Penny Enterprises Production
    00014
    00015   Change History:
    00016
    00017   10-31-96  A-RobKj (Pretty Penny Enterprises) began encapsulating
    00018   11-22-96  A-RobKj changed associations from string array to uint array to
    00019                     facilitate the spec'd device naming conventions, and
    00020                     filtering of lists for previously installed devices.
    00021
    00022   12-04-96  A-RobKj Added the CProfileArray class to make the Device
    00023                     management UI more efficient.
    00024
    00025   12-13-96  A-RobKj Moved the CDeviceList derived classes here, so I can use
    00026                     them elsewhere.
    00027
    00028 ******************************************************************************/
    00029
    00030 #if !defined(ICC_PROFILE_CLASS)
    00031
    00032 #define ICC_PROFILE_CLASS
    00033
    00034 #include    "StringAr.H"
    00035 #include    "Dialog.H"
    00036
    00037 //  CDeviceList class
    00038
    00039 /******************************************************************************
    00040
    00041   Highlights:
    00042
    00043   This is a base class for the enumeration and reporting of Device
    00044   class-specific information.  The spec is such that a device can be associated
    00045   with a friendly name, but displayed in the UI with an enhanced name.  Also,
    00046   the method for enumerating a device can differ from class to class.
    00047
    00048   This base class is usable for cases where there is no means of enumerating
    00049   devices currently.  It reports that there are no devices.
    00050   To make overrides easier, the default display name returns the friendly name,
    00051   so derived classes where this is the case do not need to override this
    00052   method.
    00053
    00054 ******************************************************************************/
    00055
    00056 class CDeviceList { //  Device-specific information- base class
    00057     CString m_csDummy;
    00058
    00059 public:
    00060     CDeviceList() {}
    00061     ~CDeviceList() {}
    00062
    00063     virtual unsigned    Count() { return    0; }
    00064     virtual CString&    DeviceName(unsigned u) { return m_csDummy; }
    00065     virtual CString&    DisplayName(unsigned u) { return DeviceName(u); }
    00066     virtual void        Enumerate() {}
    00067     virtual BOOL        IsValidDeviceName(LPCTSTR lpstr) { return FALSE; }
    00068 };
    00069
    00070 //  Device Enumeration classes- these must all derive from CDeviceList
    00071
    00072 //  The CPrinterList class handles printers.  Enumeration is via the Win32
    00073 //  spooler API.
    00074
    00075 class CPrinterList : public CDeviceList {
    00076     CStringArray    m_csaDeviceNames;
    00077     CStringArray    m_csaDisplayNames;
    00078
    00079 public:
    00080     CPrinterList() {}
    00081     ~CPrinterList() {}
    00082
    00083     virtual unsigned    Count() { return m_csaDeviceNames.Count(); }
    00084     virtual CString&    DeviceName(unsigned u) { return m_csaDeviceNames[u]; }
    00085     virtual CString&    DisplayName(unsigned u) { return m_csaDisplayNames[u]; }
    00086
    00087     virtual void        Enumerate();
    00088     virtual BOOL        IsValidDeviceName(LPCTSTR lpstr);
    00089 };
    00090
    00091 //  The CMonitorList class handles monitors.  Enumeration is via a private ICM
    00092 //  API.
    00093
    00094 class CMonitorList : public CDeviceList {
    00095     CStringArray    m_csaDeviceNames;
    00096     CStringArray    m_csaDisplayNames;
    00097
    00098     CString         m_csPrimaryDeviceName;
    00099
    00100 public:
    00101     CMonitorList() {}
    00102     ~CMonitorList() {}
    00103
    00104     virtual unsigned    Count() { return m_csaDeviceNames.Count(); }
    00105     virtual CString&    DeviceName(unsigned u) { return m_csaDeviceNames[u]; }
    00106     virtual CString&    DisplayName(unsigned u) { return m_csaDisplayNames[u]; }
    00107
    00108     virtual CString&    PrimaryDeviceName() { return m_csPrimaryDeviceName; }
    00109
    00110     virtual void        Enumerate();
    00111     virtual BOOL        IsValidDeviceName(LPCTSTR lpstr);
    00112
    00113     virtual LPCSTR      DeviceNameToDisplayName(LPCTSTR lpstr);
    00114 };
    00115
    00116 //  The CScannerList class handles scanners.  Enumeration is via the STI
    00117 //  interface.
    00118
    00119 class CScannerList : public CDeviceList {
    00120     CStringArray    m_csaDeviceNames;
    00121     CStringArray    m_csaDisplayNames;
    00122
    00123 public:
    00124     CScannerList() {}
    00125     ~CScannerList() {}
    00126
    00127     virtual unsigned    Count() { return m_csaDeviceNames.Count(); }
    00128     virtual CString&    DeviceName(unsigned u) { return m_csaDeviceNames[u]; }
    00129     virtual CString&    DisplayName(unsigned u) { return m_csaDisplayNames[u]; }
    00130
    00131     virtual void        Enumerate();
    00132     virtual BOOL        IsValidDeviceName(LPCTSTR lpstr);
    00133 };
    00134
    00135 //  The CAllDeviceList class shows everything.  We enumerate by combining the
    00136 //  results of enumerating all of the other classes.
    00137
    00138 class CAllDeviceList : public CDeviceList {
    00139     CStringArray    m_csaDeviceNames;
    00140     CStringArray    m_csaDisplayNames;
    00141
    00142 public:
    00143     CAllDeviceList() {}
    00144     ~CAllDeviceList() {}
    00145
    00146     virtual unsigned    Count() { return m_csaDeviceNames.Count(); }
    00147     virtual CString&    DeviceName(unsigned u) { return m_csaDeviceNames[u]; }
    00148     virtual CString&    DisplayName(unsigned u) { return m_csaDisplayNames[u]; }
    00149
    00150     virtual void        Enumerate();
    00151     virtual BOOL        IsValidDeviceName(LPCTSTR lpstr);
    00152 };
    00153
    00154 //  CProfile class
    00155
    00156 class CProfile {
    00157
    00158     HPROFILE        m_hprof;                //  Profile handle
    00159     PROFILEHEADER   m_phThis;               //  Profile header
    00160     CString         m_csName;
    00161     BOOL            m_bIsInstalled, m_bInstallChecked, m_bAssociationsChecked,
    00162                     m_bDevicesChecked;
    00163     CDeviceList     *m_pcdlClass;           //  Devices of this class
    00164     CUintArray      m_cuaAssociation;       //  Associated devices (indices)
    00165     char            m_acTag[MAX_PATH * 2];
    00166     void    InstallCheck();
    00167     void    AssociationCheck();
    00168     void    DeviceCheck();
    00169
    00170 public:
    00171
    00172     static void Enumerate(ENUMTYPE& et, CStringArray& csaList);
    00173     static void Enumerate(ENUMTYPE& et, CStringArray& csaList, CStringArray& csaDesc);
    00174     static void Enumerate(ENUMTYPE& et, class CProfileArray& cpaList);
    00175     static const CString  ColorDirectory();
    00176
    00177     CProfile(LPCTSTR lpstr);
    00178     ~CProfile();
    00179
    00180     //  Queries
    00181
    00182     CString GetName() { return m_csName.NameOnly(); }
    00183     DWORD   GetType() { return m_hprof ? m_phThis.phClass : 0; }
    00184     DWORD   GetCMM()  { return m_hprof ? m_phThis.phCMMType : 0; }
    00185
    00186     // Inquire the color space information from the header
    00187     DWORD   GetColorSpace() {return m_hprof ? m_phThis.phDataColorSpace : 0;}
    00188
    00189     BOOL    IsInstalled() {
    00190         if  (!m_bInstallChecked)
    00191             InstallCheck();
    00192         return m_bIsInstalled;
    00193     }
    00194     BOOL    IsValid() {
    00195         BOOL bValid = FALSE;
    00196
    00197         if (m_hprof)
    00198             IsColorProfileValid(m_hprof, &bValid);
    00199
    00200         return  bValid;
    00201     }
    00202
    00203     unsigned    DeviceCount() {
    00204         if (m_pcdlClass) {
    00205           if (!m_bDevicesChecked)
    00206               DeviceCheck();
    00207           return m_pcdlClass -> Count();
    00208         } else {
    00209           return 0;                           // low memory - m_pcdlClass allocation failed
    00210         }
    00211     }
    00212
    00213     unsigned    AssociationCount() {
    00214         if  (!m_bAssociationsChecked)
    00215             AssociationCheck();
    00216         return m_cuaAssociation.Count();
    00217     }
    00218
    00219     LPCTSTR     DeviceName(unsigned u) {
    00220         if (m_pcdlClass) {
    00221           if  (!m_bDevicesChecked)
    00222               DeviceCheck();
    00223           return m_pcdlClass -> DeviceName(u);
    00224         } else {
    00225           return TEXT("");                    // low memory - m_pcdlClass allocation failed
    00226         }
    00227     }
    00228
    00229     LPCTSTR     DisplayName(unsigned u) {
    00230         if (m_pcdlClass) {
    00231           if  (!m_bDevicesChecked)
    00232               DeviceCheck();
    00233           return m_pcdlClass -> DisplayName(u);
    00234         } else {
    00235           return TEXT("");                    // low memory - m_pcdlClass allocation failed
    00236         }
    00237     }
    00238
    00239     unsigned    Association(unsigned u) {
    00240         if  (!m_bAssociationsChecked)
    00241             AssociationCheck();
    00242         return m_cuaAssociation[u];
    00243     }
    00244
    00245     LPCSTR      TagContents(TAGTYPE tt, unsigned uOffset = 0);
    00246
    00247     //  Operations
    00248
    00249     BOOL    Install();
    00250     void    Uninstall(BOOL bDelete);
    00251     void    Associate(LPCTSTR lpstrNew);
    00252     void    Dissociate(LPCTSTR lpstrNew);
    00253
    00254 };
    00255
    00256 //  CProfileArray class- this is a list of profiles- it is used by the Device
    00257 //  Management UI, so we only construct a CProfile object once per profile.
    00258
    00259 class   CProfileArray {
    00260     CProfile        *m_aStore[20];
    00261     CProfileArray   *m_pcpaNext;
    00262     unsigned        m_ucUsed;
    00263
    00264     const unsigned ChunkSize() const {
    00265         return sizeof m_aStore / sizeof m_aStore[0];
    00266     }
    00267
    00268     CProfile    *Borrow();
    00269
    00270 public:
    00271
    00272     CProfileArray();
    00273     ~CProfileArray();
    00274
    00275     unsigned    Count() const { return m_ucUsed; }
    00276
    00277     //  Add an item
    00278     void        Add(LPCTSTR lpstrNew);
    00279
    00280     CProfile    *operator [](unsigned u) const;
    00281
    00282     void        Remove(unsigned u);
    00283     void        Empty();
    00284 };
    00285
    00286 #endif