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.

219 lines
6.1 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. faxshell.h
  5. Abstract:
  6. definitions for faxshell.cpp
  7. Author:
  8. Andrew Ritz (andrewr) 2-27-98
  9. Environment:
  10. user-mode
  11. Notes:
  12. Revision History:
  13. 2-27-98 (andrewr) Created.
  14. 8-06-99 (steveke) Major rewrite -> changed from shell extension to column provider
  15. --*/
  16. #define REGKEY_CLASSES_CLSID L"Clsid"
  17. #define REGKEY_FAXSHELL_CLSID L"{7f9609be-af9a-11d1-83e0-00c04fb6e984}"
  18. #define REGVAL_FAXSHELL_TEXT L"Fax Tiff Data Column Provider"
  19. #define REGKEY_INPROC L"InProcServer32"
  20. #define REGVAL_THREADING L"ThreadingModel"
  21. #define REGVAL_APARTMENT L"Apartment"
  22. #define REGVAL_LOCATION L"%SystemRoot%\\system32\\faxshell.dll"
  23. #define REGKEY_COLUMNHANDLERS L"Folder\\shellex\\ColumnHandlers"
  24. // g_hInstance is a global handle to the instance of the dll
  25. HINSTANCE g_hInstance = NULL;
  26. // cLockCount is the lock count on the dll
  27. LONG cLockCount = 0;
  28. // CLSID_FaxShellExtension is the class id: 7f9609be-af9a-11d1-83e0-00c04fb6e984
  29. DEFINE_GUID (CLSID_FaxShellExtension, 0x7f9609be, 0xaf9a, 0x11d1, 0x83, 0xe0, 0x00, 0xc0, 0x4f, 0xb6, 0xe9, 0x84);
  30. // PSGUID_FAXSHELLEXTENSION is the class guid: 7f9609be-af9a-11d1-83e0-00c04fb6e984
  31. #define PSGUID_FAXSHELLEXTENSION {0x7f9609be, 0xaf9a, 0x11d1, 0x83, 0xe0, 0x00, 0xc0, 0x4f, 0xb6, 0xe9, 0x84}
  32. // PID_* are column property identifiers
  33. #define PID_SENDERNAME 0
  34. #define PID_RECIPIENTNAME 1
  35. #define PID_RECIPIENTNUMBER 2
  36. #define PID_CSID 3
  37. #define PID_TSID 4
  38. #define PID_RECEIVETIME 5
  39. #define PID_CALLERID 6
  40. #define PID_ROUTING 7
  41. // SCID_* are SHCOLUMNID structures that uniquely indentify the columns
  42. SHCOLUMNID SCID_SenderName = { PSGUID_FAXSHELLEXTENSION, PID_SENDERNAME };
  43. SHCOLUMNID SCID_RecipientName = { PSGUID_FAXSHELLEXTENSION, PID_RECIPIENTNAME };
  44. SHCOLUMNID SCID_RecipientNumber = { PSGUID_FAXSHELLEXTENSION, PID_RECIPIENTNUMBER };
  45. SHCOLUMNID SCID_Csid = { PSGUID_FAXSHELLEXTENSION, PID_CSID };
  46. SHCOLUMNID SCID_Tsid = { PSGUID_FAXSHELLEXTENSION, PID_TSID };
  47. SHCOLUMNID SCID_ReceiveTime = { PSGUID_FAXSHELLEXTENSION, PID_RECEIVETIME };
  48. SHCOLUMNID SCID_CallerId = { PSGUID_FAXSHELLEXTENSION, PID_CALLERID };
  49. SHCOLUMNID SCID_Routing = { PSGUID_FAXSHELLEXTENSION, PID_ROUTING };
  50. typedef struct _COLUMN_TABLE
  51. {
  52. SHCOLUMNID *pscid; // SHCOLUMNID structure that uniquely identifies the column
  53. DWORD dwId; // Resource id of the column name
  54. DWORD dwSize; // Resource size of the column name
  55. VARTYPE vt; // Variant type of the column's data
  56. } COLUMN_TABLE;
  57. const COLUMN_TABLE ColumnTable[] =
  58. {
  59. { &SCID_SenderName, IDS_COL_SENDERNAME, MAX_COLUMN_NAME_LEN, VT_BSTR },
  60. { &SCID_RecipientName, IDS_COL_RECIPIENTNAME, MAX_COLUMN_NAME_LEN, VT_BSTR },
  61. { &SCID_RecipientNumber, IDS_COL_RECIPIENTNUMBER, MAX_COLUMN_NAME_LEN, VT_BSTR },
  62. { &SCID_Csid, IDS_COL_CSID, MAX_COLUMN_NAME_LEN, VT_BSTR },
  63. { &SCID_Tsid, IDS_COL_TSID, MAX_COLUMN_NAME_LEN, VT_BSTR },
  64. { &SCID_ReceiveTime, IDS_COL_RECEIVETIME, MAX_COLUMN_NAME_LEN, VT_BSTR },
  65. { &SCID_CallerId, IDS_COL_CALLERID, MAX_COLUMN_NAME_LEN, VT_BSTR },
  66. { &SCID_Routing, IDS_COL_ROUTING, MAX_COLUMN_NAME_LEN, VT_BSTR },
  67. };
  68. // ColumnTableCount is the number of entries in the column table
  69. #define ColumnTableCount (sizeof(ColumnTable) / sizeof(COLUMN_TABLE))
  70. class CClassFactory : public IClassFactory
  71. {
  72. public:
  73. // IUnknown methods
  74. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvOut)
  75. {
  76. static const QITAB qit[] =
  77. {
  78. QITABENT(CClassFactory, IClassFactory), // IID_IClassFactory
  79. { 0 },
  80. };
  81. return QISearch(this, qit, riid, ppvOut);
  82. };
  83. virtual STDMETHODIMP_(ULONG) AddRef()
  84. {
  85. return InterlockedIncrement(&cObjectCount);
  86. };
  87. virtual STDMETHODIMP_(ULONG) Release()
  88. {
  89. if (InterlockedDecrement(&cObjectCount) != 0)
  90. {
  91. return cObjectCount;
  92. }
  93. delete this;
  94. return 0;
  95. };
  96. // IClassFactory methods
  97. virtual STDMETHODIMP CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID FAR *ppvOut);
  98. virtual STDMETHODIMP LockServer(BOOL fLock)
  99. {
  100. (fLock == TRUE) ? InterlockedIncrement(&cLockCount) : InterlockedDecrement(&cLockCount);
  101. return S_OK;
  102. }
  103. CClassFactory() : cObjectCount(1)
  104. {
  105. LockServer(TRUE);
  106. }
  107. virtual ~CClassFactory()
  108. {
  109. LockServer(FALSE);
  110. }
  111. private:
  112. // cObjectCount is the reference count of the object
  113. LONG cObjectCount;
  114. };
  115. class CFaxColumnProvider : public IColumnProvider
  116. {
  117. public:
  118. // IUnknown methods
  119. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvOut)
  120. {
  121. static const QITAB qit[] =
  122. {
  123. QITABENT(CFaxColumnProvider, IColumnProvider), // IID_IColumnProvider
  124. { 0 },
  125. };
  126. return QISearch(this, qit, riid, ppvOut);
  127. };
  128. virtual STDMETHODIMP_(ULONG) AddRef()
  129. {
  130. return InterlockedIncrement(&cObjectCount);
  131. };
  132. virtual STDMETHODIMP_(ULONG) Release()
  133. {
  134. if (InterlockedDecrement(&cObjectCount) != 0)
  135. {
  136. return cObjectCount;
  137. }
  138. if (m_IFaxTiff != NULL)
  139. {
  140. m_IFaxTiff->Release();
  141. }
  142. delete this;
  143. return 0;
  144. };
  145. // IColumnProvider methods
  146. virtual STDMETHODIMP Initialize(LPCSHCOLUMNINIT psci) {return S_OK;};
  147. virtual STDMETHODIMP GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO *psci);
  148. virtual STDMETHODIMP GetItemData(LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvarData);
  149. CFaxColumnProvider() : cObjectCount(1), m_IFaxTiff(NULL)
  150. {
  151. InterlockedIncrement(&cLockCount);
  152. }
  153. virtual ~CFaxColumnProvider()
  154. {
  155. InterlockedDecrement(&cLockCount);
  156. }
  157. private:
  158. // m_IFaxTiff is the IFaxTiff object
  159. IFaxTiff* m_IFaxTiff;
  160. // cObjectCount is the reference count of the object
  161. LONG cObjectCount;
  162. };