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.

220 lines
6.6 KiB

  1. /*
  2. * MAIN.CPP
  3. *
  4. *
  5. *
  6. *
  7. *
  8. *
  9. */
  10. #include <windows.h>
  11. #include <hidclass.h>
  12. #include <hidsdi.h>
  13. #include <ole2.h>
  14. #include <ole2ver.h>
  15. #include "..\inc\opos.h"
  16. #include "oposctrl.h"
  17. struct controlType controlTypes[] =
  18. {
  19. { CONTROL_BUMP_BAR, "BumpBar" },
  20. { CONTROL_CASH_CHANGER, "CashChanger" },
  21. { CONTROL_CASH_DRAWER, "CashDrawer" },
  22. { CONTROL_COIN_DISPENSER, "CoinDispenser" },
  23. { CONTROL_FISCAL_PRINTER, "FiscalPrinter" },
  24. { CONTROL_HARD_TOTALS, "HardTotals" },
  25. { CONTROL_KEYLOCK, "Keylock" },
  26. { CONTROL_LINE_DISPLAY, "LineDisplay" },
  27. { CONTROL_MICR, "MICR" },
  28. { CONTROL_MSR, "MSR" },
  29. { CONTROL_PIN_PAD, "PINPad" },
  30. { CONTROL_POS_KEYBOARD, "POSKeyboard" },
  31. { CONTROL_POS_PRINTER, "POSPrinter" },
  32. { CONTROL_REMOTE_ORDER_DISPLAY, "RemoteOrderDisplay" },
  33. { CONTROL_SCALE, "Scale" },
  34. { CONTROL_SCANNER, "Scanner" },
  35. { CONTROL_SIGNATURE_CAPTURE, "SignatureCapture" },
  36. { CONTROL_TONE_INDICATOR, "ToneIndicator" },
  37. { CONTROL_LAST, "" }
  38. };
  39. /*
  40. ************************************************************
  41. * DllMain
  42. ************************************************************
  43. *
  44. *
  45. */
  46. STDAPI_(BOOL) DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID lpReserved)
  47. {
  48. BOOLEAN result;
  49. switch (dwReason){
  50. case DLL_PROCESS_ATTACH:
  51. Report("DllMain: DLL_PROCESS_ATTACH", dwReason); // BUGBUG REMOVE
  52. result = TRUE;
  53. break;
  54. case DLL_PROCESS_DETACH:
  55. Report("DllMain: DLL_PROCESS_DETACH", dwReason); // BUGBUG REMOVE
  56. result = TRUE;
  57. break;
  58. case DLL_THREAD_ATTACH:
  59. Report("DllMain: DLL_THREAD_ATTACH", dwReason); // BUGBUG REMOVE
  60. result = TRUE;
  61. break;
  62. case DLL_THREAD_DETACH:
  63. Report("DllMain: DLL_THREAD_DETACH", dwReason); // BUGBUG REMOVE
  64. result = TRUE;
  65. break;
  66. default:
  67. Report("DllMain", dwReason); // BUGBUG REMOVE
  68. result = TRUE;
  69. break;
  70. }
  71. return result;
  72. }
  73. void OpenServer()
  74. {
  75. HRESULT hres;
  76. hres = OleInitialize(NULL);
  77. if ((hres == S_OK) || (hres == S_FALSE)){
  78. IOPOSService *iOposService = NULL;
  79. Report("Ole is initialized, calling CoCreateInstance", (DWORD)hres);
  80. /*
  81. * Create an instance of the OPOS server object
  82. * and get a pointer to it's server interface.
  83. * CoCreateInstance is simply a wrapper for
  84. * CoGetClassObject + CreateInstance on that object.
  85. */
  86. hres = CoCreateInstance(
  87. GUID_HID_OPOS_SERVER,
  88. NULL,
  89. CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER,
  90. IID_HID_OPOS_SERVER,
  91. (PVOID *)&iOposService);
  92. if (hres == S_OK){
  93. Report("CoCreateInstance got server's interface", (DWORD)iOposService);
  94. // xxx
  95. }
  96. else {
  97. ReportHresultErr("CoCreateInstance failed", (DWORD)hres);
  98. }
  99. }
  100. else {
  101. Report("OleInitialize failed", (DWORD)hres);
  102. }
  103. }
  104. // BUGBUG - this runs contrary to the spec (supposed to be a method)
  105. /*
  106. *
  107. *
  108. */
  109. IOPOSControl *OpenControl(PCHAR DeviceName)
  110. {
  111. IOPOSControl *iOposControl;
  112. int i;
  113. for (i = 0; controlTypes[i].type != CONTROL_LAST; i++){
  114. if (!lstrcmpi((LPSTR)DeviceName, controlTypes[i].deviceName)){
  115. break;
  116. }
  117. }
  118. switch (controlTypes[i].type){
  119. case CONTROL_BUMP_BAR:
  120. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSBumpBar;
  121. break;
  122. case CONTROL_CASH_CHANGER:
  123. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSCashChanger;
  124. break;
  125. case CONTROL_CASH_DRAWER:
  126. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSCashDrawer;
  127. break;
  128. case CONTROL_COIN_DISPENSER:
  129. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSCoinDispenser;
  130. break;
  131. case CONTROL_FISCAL_PRINTER:
  132. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSFiscalPrinter;
  133. break;
  134. case CONTROL_HARD_TOTALS:
  135. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSHardTotals;
  136. break;
  137. case CONTROL_KEYLOCK:
  138. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSKeyLock;
  139. break;
  140. case CONTROL_LINE_DISPLAY:
  141. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSLineDisplay;
  142. break;
  143. case CONTROL_MICR:
  144. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSMICR;
  145. break;
  146. case CONTROL_MSR:
  147. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSMSR;
  148. break;
  149. case CONTROL_PIN_PAD:
  150. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSPinPad;
  151. break;
  152. case CONTROL_POS_KEYBOARD:
  153. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSKeyboard;
  154. break;
  155. case CONTROL_POS_PRINTER:
  156. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSPrinter;
  157. break;
  158. case CONTROL_REMOTE_ORDER_DISPLAY:
  159. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSRemoteOrderDisplay;
  160. break;
  161. case CONTROL_SCALE:
  162. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSScale;
  163. break;
  164. case CONTROL_SCANNER:
  165. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSScanner;
  166. break;
  167. case CONTROL_SIGNATURE_CAPTURE:
  168. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSSignatureCapture;
  169. break;
  170. case CONTROL_TONE_INDICATOR:
  171. iOposControl = (IOPOSControl *)(COPOSControl *)new COPOSToneIndicator;
  172. break;
  173. case CONTROL_LAST:
  174. default:
  175. iOposControl = NULL;
  176. break;
  177. }
  178. if (iOposControl){
  179. iOposControl->AddRef();
  180. }
  181. else {
  182. Report("Open failed", controlTypes[i].type);
  183. }
  184. return iOposControl;
  185. }