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.

169 lines
5.6 KiB

  1. //Copyright (c) 1998 - 2001 Microsoft Corporation
  2. #include <assert.h>
  3. #include "precomp.h"
  4. #include "wwwreg.h"
  5. #include "fancypasting.h"
  6. #include "licensinglink.h"
  7. void MoveCaret(int nID, HWND hwnd ) ;
  8. void SetDeleteKeyStatus(int iValue) ;
  9. LRW_DLG_INT CALLBACK
  10. WWWRegProc(
  11. IN HWND hwnd,
  12. IN UINT uMsg,
  13. IN WPARAM wParam,
  14. IN LPARAM lParam
  15. )
  16. {
  17. DWORD dwNextPage = 0;
  18. BOOL bStatus = TRUE;
  19. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  20. DWORD dwReturn;
  21. HWND hwndLSID;
  22. TCHAR * cwLicenseServerID;
  23. TCHAR tcUserValue[ CHARS_IN_BATCH*NUMBER_OF_BATCHES + 1];
  24. switch (uMsg)
  25. {
  26. case WM_INITDIALOG:
  27. // Now set the Limit of the data entry fields
  28. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO1, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  29. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO2, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  30. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO3, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  31. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO4, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  32. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO5, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  33. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO6, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  34. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO7, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  35. assert(NUMBER_OF_BATCHES == 7);
  36. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO1), _T(""));
  37. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO2), _T(""));
  38. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO3), _T(""));
  39. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO4), _T(""));
  40. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO5), _T(""));
  41. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO6), _T(""));
  42. SetWindowText(GetDlgItem(hwnd, IDC_TXT_TELEINFO7), _T(""));
  43. AddLicensingSiteLink(hwnd);
  44. break;
  45. case WM_DESTROY:
  46. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  47. break;
  48. case WM_COMMAND:
  49. if (HIWORD(wParam) == EN_CHANGE)
  50. MoveCaret(LOWORD(wParam), hwnd ) ;
  51. if (HIWORD(wParam) == EN_UPDATE)
  52. {
  53. if (GetKeyState(VK_DELETE) == -128)
  54. SetDeleteKeyStatus(1) ;
  55. else
  56. SetDeleteKeyStatus(0) ;
  57. }
  58. if (HIWORD(wParam) == EN_MAXTEXT)
  59. {
  60. //Only insert if the paste operation
  61. //originated in the leftmost edit field
  62. if (LOWORD(wParam) == IDC_TXT_TELEINFO1)
  63. InsertClipboardDataIntoIDFields(hwnd, IDC_TXT_TELEINFO1, IDC_TXT_TELEINFO7);
  64. }
  65. break;
  66. case WM_NOTIFY:
  67. {
  68. LPNMHDR pnmh = (LPNMHDR)lParam;
  69. switch( pnmh->code )
  70. {
  71. case PSN_SETACTIVE:
  72. cwLicenseServerID = GetLicenseServerID();
  73. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT|PSWIZB_BACK);
  74. // Get the License Server ID, provided by the License Server
  75. hwndLSID = GetDlgItem(hwnd, IDC_PRODUCT_ID);
  76. SetWindowText(hwndLSID, cwLicenseServerID);
  77. AddLicensingSiteLink(hwnd);
  78. break;
  79. case PSN_WIZNEXT:
  80. // Let us get the Information Entered First & concatenate everything into
  81. // One String
  82. GetDlgItemText(hwnd,IDC_TXT_TELEINFO1, tcUserValue, CHARS_IN_BATCH+1);
  83. GetDlgItemText(hwnd,IDC_TXT_TELEINFO2, tcUserValue+1*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  84. GetDlgItemText(hwnd,IDC_TXT_TELEINFO3, tcUserValue+2*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  85. GetDlgItemText(hwnd,IDC_TXT_TELEINFO4, tcUserValue+3*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  86. GetDlgItemText(hwnd,IDC_TXT_TELEINFO5, tcUserValue+4*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  87. GetDlgItemText(hwnd,IDC_TXT_TELEINFO6, tcUserValue+5*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  88. GetDlgItemText(hwnd,IDC_TXT_TELEINFO7, tcUserValue+6*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  89. // OK, Now we have the Information provided by the user
  90. // Need to validate
  91. if (wcsspn(tcUserValue, BASE24_CHARACTERS) != LR_REGISTRATIONID_LEN)
  92. {
  93. // Extraneous characters in the SPK string
  94. LRMessageBox(hwnd, IDS_ERR_INVALIDLSID,IDS_ACTIVATION_TITLE);
  95. dwNextPage = IDD_DLG_WWWREG;
  96. }
  97. else
  98. {
  99. dwReturn = GetGlobalContext()->SetLSSPK(tcUserValue);
  100. if (dwReturn != ERROR_SUCCESS)
  101. {
  102. LRMessageBox(hwnd, dwReturn, NULL, LRGetLastError());
  103. dwNextPage = IDD_DLG_WWWREG;
  104. }
  105. else
  106. {
  107. dwReturn = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  108. dwNextPage = IDD_PROGRESS;
  109. LRPush(IDD_DLG_WWWREG);
  110. }
  111. }
  112. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  113. bStatus = -1;
  114. break;
  115. case PSN_WIZBACK:
  116. dwNextPage = LRPop();
  117. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  118. bStatus = -1;
  119. break;
  120. case NM_CHAR:
  121. if( ( ( LPNMCHAR )lParam )->ch != VK_SPACE )
  122. break;
  123. // else fall through
  124. case NM_RETURN:
  125. case NM_CLICK:
  126. {
  127. //A value less than 32 indicates an error launching the process
  128. if ((ShellExecute(NULL, L"open", GetWWWSite(), NULL, NULL, SW_SHOWNORMAL)) <= (HINSTANCE)32)
  129. {
  130. TCHAR lpBuffer[512];
  131. memset(lpBuffer,0,sizeof(lpBuffer));
  132. LoadString(GetInstanceHandle(), IDS_WWW_BROWSER_LAUNCH_ERROR, lpBuffer, sizeof(lpBuffer)/sizeof(TCHAR));
  133. }
  134. break;
  135. }
  136. default:
  137. bStatus = FALSE;
  138. break;
  139. }
  140. }
  141. break;
  142. default:
  143. bStatus = FALSE;
  144. break;
  145. }
  146. return bStatus;
  147. }