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.

184 lines
4.5 KiB

  1. /*****************************************************************************\
  2. * MODULE: ppchange.h
  3. *
  4. * This module contains functions that handle notification
  5. *
  6. *
  7. * Copyright (C) 1996-1997 Microsoft Corporation
  8. *
  9. * History:
  10. * 28-Apr-1998 Weihai Chen (weihaic)
  11. *
  12. \*****************************************************************************/
  13. #include "precomp.h"
  14. #include "priv.h"
  15. typedef struct INET_HPRINTER_LIST {
  16. LPINET_HPRINTER hPrinter;
  17. struct INET_HPRINTER_LIST *next;
  18. } INET_HPRINTER_LIST;
  19. typedef INET_HPRINTER_LIST *PINET_HPRINTER_LIST;
  20. typedef INET_HPRINTER_LIST *NPINET_HPRINTER_LIST;
  21. typedef INET_HPRINTER_LIST *LPINET_HPRINTER_LIST;
  22. static INET_HPRINTER_LIST g_pHandleList = {NULL, NULL};
  23. /*****************************************************************************\
  24. * AddHandleToList
  25. *
  26. * Add the printer handle to a global link list
  27. *
  28. \*****************************************************************************/
  29. BOOL
  30. AddHandleToList (
  31. LPINET_HPRINTER hPrinter
  32. )
  33. {
  34. LPINET_HPRINTER_LIST pPrt;
  35. if (pPrt = (LPINET_HPRINTER_LIST)memAlloc(sizeof(INET_HPRINTER_LIST))) {
  36. pPrt->next = g_pHandleList.next;
  37. pPrt->hPrinter = hPrinter;
  38. g_pHandleList.next = pPrt;
  39. return TRUE;
  40. }
  41. else
  42. return FALSE;
  43. }
  44. /*****************************************************************************\
  45. * DeleteHandleFromList
  46. *
  47. * Remove a printer handle from the global link list
  48. *
  49. \*****************************************************************************/
  50. BOOL
  51. DeleteHandleFromList (
  52. LPINET_HPRINTER hPrinter
  53. )
  54. {
  55. LPINET_HPRINTER_LIST pPrt = &g_pHandleList;
  56. LPINET_HPRINTER_LIST pTmp;
  57. while (pPrt->next) {
  58. if (pPrt->next->hPrinter == hPrinter) {
  59. pTmp = pPrt->next;
  60. pPrt->next = pTmp->next;
  61. memFree (pTmp, sizeof(INET_HPRINTER_LIST));
  62. return TRUE;
  63. }
  64. pPrt = pPrt->next;
  65. }
  66. return FALSE;
  67. }
  68. /*****************************************************************************\
  69. * RefreshNotificationPort
  70. *
  71. * Go through the handle list and call the refresh if the notify handle is not
  72. * null
  73. *
  74. \*****************************************************************************/
  75. void
  76. RefreshNotificationPort (
  77. HANDLE hPort
  78. )
  79. {
  80. LPINET_HPRINTER_LIST pPrt = g_pHandleList.next;
  81. DBG_MSG(DBG_LEV_CALLTREE, (TEXT("Call: RefreshNotificationPort: Port(%08lX)"), hPort));
  82. while (pPrt) {
  83. if (utlValidatePrinterHandle (pPrt->hPrinter) == hPort) {
  84. if (pPrt->hPrinter->hNotify) {
  85. DBG_MSG(DBG_LEV_CALLTREE, (TEXT("Call: ReplyPrinterChangeNotification: hNotify(%08lX)"),
  86. pPrt->hPrinter->hNotify));
  87. ReplyPrinterChangeNotification (pPrt->hPrinter->hNotify,
  88. PRINTER_CHANGE_ALL,
  89. NULL,
  90. NULL);
  91. }
  92. }
  93. pPrt = pPrt->next;
  94. }
  95. }
  96. /*****************************************************************************\
  97. * RefreshNotification
  98. *
  99. * Go through the handle list and call the refresh if the notify handle is not
  100. * null
  101. *
  102. \*****************************************************************************/
  103. void
  104. RefreshNotification (
  105. LPINET_HPRINTER hPrinter
  106. )
  107. {
  108. RefreshNotificationPort (hPrinter->hPort);
  109. }
  110. /*****************************************************************************\
  111. * PPFindFirstPrinterChangeNotification
  112. *
  113. * Handle the notification request
  114. *
  115. \*****************************************************************************/
  116. BOOL
  117. PPFindFirstPrinterChangeNotification(
  118. HANDLE hPrinter,
  119. DWORD fdwFlags,
  120. DWORD fdwOptions,
  121. HANDLE hNotify,
  122. PDWORD pfdwStatus,
  123. PVOID pPrinterNotifyOptions,
  124. PVOID pPrinterNotifyInit
  125. )
  126. {
  127. static PRINTER_NOTIFY_INIT PPNotify = {
  128. sizeof (PRINTER_NOTIFY_INIT),
  129. 0,
  130. 30000
  131. };
  132. DBG_MSG(DBG_LEV_CALLTREE, (TEXT("Call: PPFindFirstPrinterChangeNotification: Printer(%08lX)"), hPrinter));
  133. DBG_MSG(DBG_LEV_CALLTREE, (TEXT("Call: hNotify(%08lX)"),hNotify));
  134. semEnterCrit();
  135. if (utlValidatePrinterHandle(hPrinter)) {
  136. ((LPINET_HPRINTER )hPrinter) ->hNotify = hNotify;
  137. fdwFlags = PRINTER_CHANGE_ALL;
  138. *pfdwStatus = PRINTER_NOTIFY_STATUS_POLL | PRINTER_NOTIFY_STATUS_ENDPOINT;
  139. * ((LPPRINTER_NOTIFY_INIT *) pPrinterNotifyInit) = &PPNotify;
  140. }
  141. semLeaveCrit ();
  142. return TRUE;
  143. }
  144. BOOL
  145. PPFindClosePrinterChangeNotification(
  146. HANDLE hPrinter
  147. )
  148. {
  149. return TRUE;
  150. }