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.

151 lines
3.4 KiB

  1. #include "private.h" // Class Definitions
  2. BOOL PromptToGoOffline(VOID);
  3. BOOL PromptToGoOnline(VOID);
  4. BOOL CALLBACK GoOfflinePromptDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  5. LPARAM lParam);
  6. BOOL CALLBACK GoOnlinePromptDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  7. LPARAM lParam);
  8. // Make sure that Notification Sinks are apartment model and hence are always called back
  9. // on the same thread making it unnecessary to use any critical sections -- APPCOMPAT
  10. // TRUE means that the state now is Online
  11. // FALSE means that the user chose to remain Offline
  12. BOOL
  13. OnConnectedNotification(void)
  14. {
  15. BOOL fRet = TRUE;
  16. // Check to see if the user is offline and wants to "go online"
  17. if((IsGlobalOffline()))
  18. {
  19. //Ask the user with a dialog
  20. fRet = PromptToGoOnline();
  21. }
  22. return fRet;
  23. }
  24. // TRUE means that the state now is Offline
  25. // FALSE means that the user chose to remain Online
  26. BOOL
  27. OnDisconnectedNotification(void)
  28. {
  29. BOOL fRet = TRUE;
  30. // Check to see if the user wants to go offline
  31. if(!(IsGlobalOffline()))
  32. {
  33. //Ask the user with a dialog, if the user says yes, then
  34. // toggle to offline mode by calling wininet
  35. fRet = PromptToGoOffline();
  36. }
  37. return fRet;
  38. }
  39. BOOL PromptToGoOffline(VOID)
  40. {
  41. // run the dialog
  42. BOOL fRet = DialogBoxParam(MLGetHinst(),MAKEINTRESOURCE(IDD_GO_OFFLINE_DLG),
  43. NULL,GoOfflinePromptDlgProc,(LPARAM) 0);
  44. return fRet;
  45. }
  46. /*******************************************************************
  47. NAME: GoOfflinePromptDlgProc
  48. SYNOPSIS: Dialog proc for Go Offline dialog
  49. ********************************************************************/
  50. BOOL CALLBACK GoOfflinePromptDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  51. LPARAM lParam)
  52. {
  53. switch (uMsg) {
  54. case WM_INITDIALOG:
  55. SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0,
  56. SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
  57. return TRUE;
  58. break;
  59. case WM_COMMAND:
  60. switch (wParam) {
  61. case IDOK:
  62. SetGlobalOffline(TRUE);
  63. EndDialog(hDlg,TRUE);
  64. return TRUE;
  65. break;
  66. case IDCANCEL:
  67. EndDialog(hDlg,FALSE);
  68. return TRUE;
  69. break;
  70. default:
  71. break;
  72. }
  73. break;
  74. default:
  75. break;
  76. }
  77. return FALSE;
  78. }
  79. BOOL PromptToGoOnline(VOID)
  80. {
  81. // run the dialog
  82. BOOL fRet = DialogBoxParam(MLGetHinst(),MAKEINTRESOURCE(IDD_GO_ONLINE_DLG),
  83. NULL,GoOnlinePromptDlgProc,(LPARAM) 0);
  84. return fRet;
  85. }
  86. /*******************************************************************
  87. NAME: GoOnlinePromptDlgProc
  88. SYNOPSIS: Dialog proc for Go Online dialog
  89. ********************************************************************/
  90. BOOL CALLBACK GoOnlinePromptDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  91. LPARAM lParam)
  92. {
  93. switch (uMsg) {
  94. case WM_INITDIALOG:
  95. return TRUE;
  96. break;
  97. case WM_COMMAND:
  98. switch (wParam) {
  99. case IDOK:
  100. SetGlobalOffline(FALSE);
  101. EndDialog(hDlg,TRUE);
  102. return TRUE;
  103. break;
  104. case IDCANCEL:
  105. EndDialog(hDlg,FALSE);
  106. return TRUE;
  107. break;
  108. default:
  109. break;
  110. }
  111. break;
  112. default:
  113. break;
  114. }
  115. return FALSE;
  116. }