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.

110 lines
3.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: D I S C O N N E C T . C P P
  7. //
  8. // Contents: Code for disconnect confirmation and SyncMgr sync calls.
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 11 Mar 1998
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "foldinc.h" // Standard shell\folder includes
  18. #include <nsres.h>
  19. #include "shutil.h"
  20. #include "disconnect.h"
  21. //+---------------------------------------------------------------------------
  22. //
  23. // Function: PromptForSyncIfNeeded
  24. //
  25. // Purpose: Query for SyncMgr processing if appropriate and call SyncMgr
  26. // if requested.
  27. //
  28. // Arguments:
  29. // pccfe [in] Our connection
  30. // hwndOwner [in] Our parent hwnd
  31. //
  32. // Author: jeffspr 31 May 1999
  33. //
  34. // Notes:
  35. //
  36. VOID PromptForSyncIfNeeded(
  37. const CONFOLDENTRY& ccfe,
  38. HWND hwndOwner)
  39. {
  40. LRESULT lResult = 0;
  41. SYNCMGRQUERYSHOWSYNCUI smqss;
  42. SYNCMGRSYNCDISCONNECT smsd;
  43. smqss.cbSize = sizeof(SYNCMGRQUERYSHOWSYNCUI);
  44. smqss.GuidConnection = ccfe.GetGuidID();
  45. smqss.pszConnectionName = ccfe.GetName();
  46. smqss.fShowCheckBox = FALSE;
  47. smqss.nCheckState = 0;
  48. // We only want to allow sync on dialup connections, and
  49. // not on incoming connections.
  50. //
  51. if (ccfe.GetNetConMediaType() == NCM_PHONE &&
  52. !(ccfe.GetCharacteristics() & NCCF_INCOMING_ONLY))
  53. {
  54. // Get the lResult, but for debugging only. We want to allow the
  55. // disconnect dialog to come up even if the sync functions failed.
  56. //
  57. lResult = SyncMgrRasProc(
  58. SYNCMGRRASPROC_QUERYSHOWSYNCUI,
  59. 0,
  60. (LPARAM) &smqss);
  61. AssertSz(lResult == 0, "Call to SyncMgrRasProc failed for the QuerySyncUI");
  62. TraceTag(ttidShellFolder, "Call to SyncMgrRasProc returned: 0x%08x", lResult);
  63. }
  64. if (smqss.fShowCheckBox)
  65. {
  66. // pop up message box and set smqss.nCheckState
  67. if(NcMsgBox(_Module.GetResourceInstance(),
  68. NULL,
  69. IDS_CONFOLD_SYNC_CONFIRM_WINDOW_TITLE,
  70. IDS_CONFOLD_SYNC_CONFIRM,
  71. smqss.nCheckState ?
  72. MB_APPLMODAL|MB_ICONEXCLAMATION|MB_YESNO:
  73. MB_APPLMODAL|MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2)
  74. == IDYES)
  75. {
  76. smqss.nCheckState = BST_CHECKED;
  77. }
  78. else
  79. {
  80. smqss.nCheckState = BST_UNCHECKED;
  81. }
  82. }
  83. // If the user wanted the sync to occur...
  84. //
  85. if (smqss.fShowCheckBox && smqss.nCheckState == BST_CHECKED)
  86. {
  87. CWaitCursor wc; // Bring up wait cursor now. Remove when we go out of scope.
  88. // Fill in the disconnect data
  89. //
  90. smsd.cbSize = sizeof(SYNCMGRSYNCDISCONNECT);
  91. smsd.GuidConnection = ccfe.GetGuidID();
  92. smsd.pszConnectionName = ccfe.GetName();
  93. // Call the syncmgr's disconnect code
  94. //
  95. lResult = SyncMgrRasProc(
  96. SYNCMGRRASPROC_SYNCDISCONNECT,
  97. 0,
  98. (LPARAM) &smsd);
  99. }
  100. }