Leaked source code of windows server 2003
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.

185 lines
6.9 KiB

  1. /*****************************************************************************
  2. * (C) COPYRIGHT MICROSOFT CORPORATION, 2002
  3. *
  4. * AUTHOR: ByronC
  5. *
  6. * DATE: 4/14/2002
  7. *
  8. * @doc INTERNAL
  9. *
  10. * @module StiEventHandlerLookup.h - Definitions for <c StiEventHandlerLookup> |
  11. *
  12. * This file contains the class definition for <c StiEventHandlerLookup>.
  13. *
  14. *****************************************************************************/
  15. //
  16. // Defines
  17. //
  18. #define StiEventHandlerLookup_UNINIT_SIG 0x55756C45
  19. #define StiEventHandlerLookup_INIT_SIG 0x49756C45
  20. #define StiEventHandlerLookup_TERM_SIG 0x54756C45
  21. #define StiEventHandlerLookup_DEL_SIG 0x44756C45
  22. #define STI_GLOBAL_EVENT_HANDLER_PATH L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\StillImage\\Registered Applications"
  23. #define STI_LAUNCH_APPPLICATIONS_VALUE L"LaunchApplications"
  24. #define STI_LAUNCH_WILDCARD L"*"
  25. #define STI_LAUNCH_SEPARATOR L","
  26. /*****************************************************************************
  27. *
  28. * @doc INTERNAL
  29. *
  30. * @class StiEventHandlerLookup | Used to find STI event handlers
  31. *
  32. * @comm
  33. * This class is used to lookup the relevant STI event handler(s) for a given
  34. * device event. This list of handlers is returned as a double NULL terminated
  35. * list of strings. This is encoded into a BSTR for use by the STI event handler prompt.
  36. *
  37. * This class is not thread safe. Caller should use separate objects or
  38. * synchronize access to the single object.
  39. *
  40. *****************************************************************************/
  41. class StiEventHandlerLookup
  42. {
  43. //@access Public members
  44. public:
  45. // @cmember Constructor
  46. StiEventHandlerLookup();
  47. // @cmember Destructor
  48. virtual ~StiEventHandlerLookup();
  49. // @cmember Increment reference count
  50. virtual ULONG __stdcall AddRef();
  51. // @cmember Decrement reference count
  52. virtual ULONG __stdcall Release();
  53. //@cmember Returns a double NULL terminated string list
  54. BSTR getStiAppListForDeviceEvent(const CSimpleStringWide &cswDeviceID, const GUID &guidEvent);
  55. // @cmember Returns a <c StiEventHandlerInfo> object describing the specified handler
  56. StiEventHandlerInfo* getHandlerFromName(const CSimpleStringWide &cswHandlerName);
  57. //
  58. // Innder class used to tokenize the device event handler strings
  59. //
  60. class SimpleStringTokenizer
  61. {
  62. public:
  63. //
  64. // Constructor which initializes the member fields. This object is intended to be used
  65. // for one pass through a string to grab the tokens. After that, it is designed to
  66. // return Empty tokens. Therefore, therefore one-time initialization of the start
  67. // position is done here.
  68. //
  69. SimpleStringTokenizer(const CSimpleString &csInput, const CSimpleString &csSeparator) :
  70. m_iStart(0),
  71. m_csSeparator(csSeparator),
  72. m_csInput(csInput)
  73. {
  74. }
  75. virtual ~SimpleStringTokenizer()
  76. {
  77. }
  78. //
  79. // Returns the next token. The last token will be empty. This indicates the end of
  80. // the input string has been reached and there are no more tokens.
  81. //
  82. CSimpleString getNextToken()
  83. {
  84. CSimpleString csToken;
  85. int iNextSeparator = 0;
  86. int iTokenLength = 0;
  87. int iTokenStart = m_iStart;
  88. //
  89. // Search for the next token. We keep searching until we hit a token of
  90. // non-zero length i.e. if the separator was ',' we would correctly
  91. // ignore the commas in the following string: ",,,,NextString,,"
  92. // We do this is by looking for the position
  93. // of the next seperator. If the token length from m_iStart to the
  94. // next separator is 0, we need to keep searching (keeping in mind
  95. // the end of input case, which is indicated when iNextSeparator == -1)
  96. //
  97. while ((iTokenLength == 0) && (iNextSeparator != -1))
  98. {
  99. m_iStart = iTokenStart;
  100. iNextSeparator = m_csInput.Find(m_csSeparator, m_iStart);
  101. iTokenLength = iNextSeparator - m_iStart;
  102. iTokenStart = iNextSeparator + 1;
  103. }
  104. //
  105. // Return the token. If we have reached the end, it will
  106. // simply be empty.
  107. //
  108. csToken = m_csInput.SubStr(m_iStart, iTokenLength);
  109. if (iNextSeparator == -1)
  110. {
  111. m_iStart = -1;
  112. }
  113. else
  114. {
  115. m_iStart = iTokenStart;
  116. }
  117. return csToken;
  118. }
  119. private:
  120. int m_iStart; // The start position of the next search for a separator.
  121. CSimpleString m_csSeparator; // Describes the separator string we use to split tokens from the input.
  122. CSimpleString m_csInput; // The input string to be tokenized
  123. };
  124. // TBD: move to private
  125. // @cmember Fills in the list of handlers
  126. VOID FillListOfHandlers(const CSimpleStringWide &cswDeviceID,
  127. const GUID &cswEventGuidString);
  128. //@access Private members
  129. private:
  130. // @cmember Frees resources associated with our list of handlers
  131. VOID ClearListOfHandlers();
  132. // @cmember Callback for each value in the registered handlers key
  133. static bool ProcessHandlers(CSimpleReg::CValueEnumInfo &enumInfo);
  134. // @cmember Signature of class
  135. ULONG m_ulSig;
  136. // @cmember Ref count
  137. ULONG m_cRef;
  138. // @cmember Ref count
  139. CSimpleLinkedList<StiEventHandlerInfo*> m_ListOfHandlers;
  140. //
  141. // Comments for member variables
  142. //
  143. // @mdata ULONG | StiEventHandlerLookup | m_ulSig |
  144. // The signature for this class, used for debugging purposes.
  145. // Doing a <nl>"db [addr_of_class]"<nl> would yield one of the following
  146. // signatures for this class:
  147. // @flag StiEventHandlerLookup_UNINIT_SIG | 'EluU' - Object has not been successfully
  148. // initialized
  149. // @flag StiEventHandlerLookup_INIT_SIG | 'EluI' - Object has been successfully
  150. // initialized
  151. // @flag StiEventHandlerLookup_TERM_SIG | 'EluT' - Object is in the process of
  152. // terminating.
  153. // @flag StiEventHandlerLookup_INIT_SIG | 'EluD' - Object has been deleted
  154. // (destructor was called)
  155. //
  156. // @mdata ULONG | StiEventHandlerLookup | m_cRef |
  157. // The reference count for this class. Used for lifetime
  158. // management.
  159. //
  160. // @mdata CSimpleLinkeList<lt>StiEventHandlerInfo*<gt> | StiEventHandlerLookup | m_ListOfGlobalHandlers |
  161. // List of global STI handlers registered for StillImage events.
  162. //
  163. };