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.

704 lines
21 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: N O T I F Y . C P P
  7. //
  8. // Contents: Implementation of INetConnectionNotifySink
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 21 Aug 1998
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "foldinc.h"
  18. #include "webview.h"
  19. #include "foldres.h" // Folder resource IDs
  20. #include "nsres.h" // Netshell strings
  21. #include "cfutils.h" // Connection folder utility functions
  22. #include "wininet.h"
  23. #include "cmdtable.h"
  24. #include "droptarget.h"
  25. // WVTI_ENTRY - Use for tasks that want to be displayed when something is selected, where the UI is
  26. // independent of the selection
  27. // WVTI_ENTRY_NOSELECTION - Use for tasks that want to be displayed when nothing is selected
  28. // WVTI_ENTRY_FILE - Use for tasks that want to be displayed when a file is selected
  29. // WVTI_ENTRY_TITLE - Use for tasks that want to be displayed when something is selected,
  30. // and you want different UI depending on the selection or if you want to control the title,
  31. // but the tooltip is constant
  32. // WVTI_ENTRY_ALL - Use this one if you want the same text everywhere
  33. // WVTI_ENTRY_ALL_TITLE - Use this one if you want to control everything
  34. // WVTI_HEADER - Use this one for a header
  35. // WVTI_HEADER_ENTRY - Use this one for a header that changes with the selection
  36. const WVTASKITEM c_ConnFolderGlobalTaskHeader =
  37. WVTI_HEADER(L"netshell.dll", // module where the resources are
  38. IDS_WV_TITLE_NETCONFOLDERTASKS, // static header for all cases
  39. IDS_WV_TITLE_NETCONFOLDERTASKS_TT // tooltip
  40. );
  41. const WVTASKITEM c_ConnFolderItemTaskHeader =
  42. WVTI_HEADER(L"netshell.dll", // module where the resources are
  43. IDS_WV_TITLE_NETCONITEMTASKS, // static header for all cases
  44. IDS_WV_TITLE_NETCONITEMTASKS_TT // tooltip
  45. );
  46. const WVTASKITEM c_ConnFolderIntro =
  47. WVTI_HEADER(L"netshell.dll", // module where the resources are
  48. IDS_WV_NETCON_INTRO, // static header for all cases
  49. IDS_WV_NETCON_INTRO // tooltip
  50. );
  51. // Use for tasks that want to be displayed when a file is selected
  52. //#define WVTI_ENTRY_FILE(g, d, t, p, i, s, k) {&(g), (d), (0), (t), (0), (0), (p), (i), (s), (k)}
  53. #define NCWVIEW_ENTRY_FILE(t, mt, i, cmd) \
  54. {&GUID_NULL, L"netshell.dll", (0), (t), (0), (mt), (IDS_##cmd), (i), (CNCWebView::CanShow##cmd), (CNCWebView::On##cmd) }
  55. const WVTASKITEM c_ConnFolderGlobalTaskList[] =
  56. {
  57. WVTI_ENTRY_ALL(
  58. GUID_NULL, // command GUID
  59. // Future thinking - something like this is the way Context Menus are done.
  60. // Be a way to get access to DefView implementation of functions - IUICmdTarget.
  61. L"netshell.dll", // module
  62. IDS_WV_MNCWIZARD, // text
  63. IDS_CMIDM_NEW_CONNECTION, // tooltip
  64. IDI_WV_MNCWIZARD, // icon
  65. CANSHOW_HANDLER_OF(CMIDM_NEW_CONNECTION),
  66. INVOKE_HANDLER_OF(CMIDM_NEW_CONNECTION)),
  67. WVTI_ENTRY_ALL(
  68. GUID_NULL, // command GUID
  69. L"netshell.dll", // module
  70. IDS_WV_HOMENET, // text
  71. IDS_CMIDM_HOMENET_WIZARD, // tooltip
  72. IDI_WV_HOMENET, // icon
  73. CANSHOW_HANDLER_OF(CMIDM_HOMENET_WIZARD),
  74. INVOKE_HANDLER_OF(CMIDM_HOMENET_WIZARD)),
  75. // Single-select Name ,Multi-select name ,Icon , Verb
  76. NCWVIEW_ENTRY_FILE(IDS_WV_CONNECT ,IDS_WM_CONNECT ,IDI_WV_CONNECT , CMIDM_CONNECT),
  77. NCWVIEW_ENTRY_FILE(IDS_WV_DISCONNECT ,IDS_WM_DISCONNECT ,IDI_WV_DISCONNECT , CMIDM_DISCONNECT),
  78. NCWVIEW_ENTRY_FILE(IDS_WV_ENABLE ,IDS_WM_ENABLE ,IDI_WV_ENABLE , CMIDM_ENABLE),
  79. NCWVIEW_ENTRY_FILE(IDS_WV_DISABLE ,IDS_WM_DISABLE ,IDI_WV_DISABLE , CMIDM_DISABLE),
  80. NCWVIEW_ENTRY_FILE(IDS_WV_REPAIR ,IDS_WM_REPAIR ,IDI_WV_REPAIR , CMIDM_FIX),
  81. NCWVIEW_ENTRY_FILE(IDS_WV_RENAME ,IDS_WM_RENAME ,IDI_WV_RENAME , CMIDM_RENAME),
  82. NCWVIEW_ENTRY_FILE(IDS_WV_STATUS ,IDS_WM_STATUS ,IDI_WV_STATUS , CMIDM_STATUS),
  83. NCWVIEW_ENTRY_FILE(IDS_WV_DELETE ,IDS_WM_DELETE ,IDI_WV_DELETE , CMIDM_DELETE),
  84. NCWVIEW_ENTRY_FILE(IDS_WV_PROPERTIES ,IDS_WM_PROPERTIES ,IDI_WV_PROPERTIES , CMIDM_PROPERTIES)
  85. };
  86. DWORD c_aOtherPlaces[] =
  87. {
  88. CSIDL_CONTROLS,
  89. CSIDL_NETWORK,
  90. CSIDL_PERSONAL,
  91. CSIDL_DRIVES
  92. };
  93. extern const DWORD c_dwCountOtherPlaces = celems(c_aOtherPlaces);
  94. const WVTASKITEM c_ConnFolderItemTaskList[] =
  95. {
  96. WVTI_ENTRY_ALL(
  97. GUID_NULL, // command GUID
  98. L"netshell.dll", // module
  99. IDS_WV_TROUBLESHOOT, // text
  100. IDS_CMIDM_NET_TROUBLESHOOT, // tooltip
  101. IDI_WV_TROUBLESHOOT, // icon
  102. CANSHOW_HANDLER_OF(CMIDM_NET_TROUBLESHOOT),
  103. INVOKE_HANDLER_OF(CMIDM_NET_TROUBLESHOOT))
  104. };
  105. CNCWebView::CNCWebView(CConnectionFolder* pConnectionFolder)
  106. {
  107. Assert(pConnectionFolder);
  108. Assert(c_dwCountOtherPlaces <= MAXOTHERPLACES);
  109. m_pConnectionFolder = pConnectionFolder;
  110. // zero the PIDLs array to other places section in the webview
  111. ZeroMemory(m_apidlOtherPlaces, sizeof(m_apidlOtherPlaces));
  112. }
  113. CNCWebView::~CNCWebView()
  114. {
  115. // check to destroy the other places PIDLs
  116. DestroyOtherPlaces();
  117. }
  118. IMPLEMENT_WEBVIEW_HANDLERS(TOPLEVEL, CNCWebView, CMIDM_NEW_CONNECTION);
  119. IMPLEMENT_WEBVIEW_HANDLERS(TOPLEVEL, CNCWebView, CMIDM_HOMENET_WIZARD);
  120. IMPLEMENT_WEBVIEW_HANDLERS(TOPLEVEL, CNCWebView, CMIDM_NET_TROUBLESHOOT);
  121. IMPLEMENT_WEBVIEW_HANDLERS(TASKLEVEL, CNCWebView, CMIDM_FIX);
  122. IMPLEMENT_WEBVIEW_HANDLERS(TASKLEVEL, CNCWebView, CMIDM_CONNECT);
  123. IMPLEMENT_WEBVIEW_HANDLERS(TASKLEVEL, CNCWebView, CMIDM_DISCONNECT);
  124. IMPLEMENT_WEBVIEW_HANDLERS(TASKLEVEL, CNCWebView, CMIDM_ENABLE);
  125. IMPLEMENT_WEBVIEW_HANDLERS(TASKLEVEL, CNCWebView, CMIDM_DISABLE);
  126. IMPLEMENT_WEBVIEW_HANDLERS(TASKLEVEL, CNCWebView, CMIDM_RENAME);
  127. IMPLEMENT_WEBVIEW_HANDLERS(TASKLEVEL, CNCWebView, CMIDM_DELETE);
  128. IMPLEMENT_WEBVIEW_HANDLERS(TASKLEVEL, CNCWebView, CMIDM_STATUS);
  129. IMPLEMENT_WEBVIEW_HANDLERS(TASKLEVEL, CNCWebView, CMIDM_PROPERTIES);
  130. HRESULT CNCWebView::OnNull(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc)
  131. {
  132. return S_OK;
  133. }
  134. STDMETHODIMP CNCWebView::RealMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
  135. {
  136. switch (uMsg)
  137. {
  138. HANDLE_MSG(0, SFVM_GETWEBVIEWLAYOUT, OnGetWebViewLayout);
  139. HANDLE_MSG(0, SFVM_GETWEBVIEWCONTENT, OnGetWebViewContent);
  140. HANDLE_MSG(0, SFVM_GETWEBVIEWTASKS, OnGetWebViewTasks);
  141. default:
  142. return E_FAIL;
  143. }
  144. }
  145. STDMETHODIMP CNCWebView::CreateOtherPlaces(LPDWORD pdwCount)
  146. {
  147. TraceFileFunc(ttidMenus);
  148. // first verify if created already
  149. HRESULT hr = S_OK;
  150. Assert(pdwCount);
  151. if (!pdwCount)
  152. {
  153. return E_INVALIDARG;
  154. }
  155. if( NULL == m_apidlOtherPlaces[0] )
  156. {
  157. *pdwCount = 0;
  158. // create the PIDLs to other places section in the webview
  159. ZeroMemory(m_apidlOtherPlaces, sizeof(m_apidlOtherPlaces));
  160. for (int dwPlaces = 0; dwPlaces < c_dwCountOtherPlaces; dwPlaces++)
  161. {
  162. if (SUCCEEDED(hr = SHGetSpecialFolderLocation(NULL, c_aOtherPlaces[dwPlaces], &(m_apidlOtherPlaces[*pdwCount]))))
  163. {
  164. (*pdwCount)++;
  165. }
  166. else
  167. {
  168. m_apidlOtherPlaces[*pdwCount] = NULL;
  169. TraceHr(ttidError, FAL, hr, FALSE, "CNCWebView::CreateOtherPlaces : 0x%04x", c_aOtherPlaces[dwPlaces]);
  170. }
  171. }
  172. if (FAILED(hr) && (*pdwCount))
  173. {
  174. hr = S_FALSE; // not a big deal if at least one worked.
  175. }
  176. }
  177. TraceHr(ttidError, FAL, hr, FALSE, "CNCWebView::CreateOtherPlaces - all places failed");
  178. return hr;
  179. }
  180. STDMETHODIMP CNCWebView::DestroyOtherPlaces()
  181. {
  182. for (ULONG i = 0; i < c_dwCountOtherPlaces; i++)
  183. {
  184. if (m_apidlOtherPlaces[i])
  185. {
  186. LPMALLOC pMalloc;
  187. if (SUCCEEDED(SHGetMalloc(&pMalloc)))
  188. {
  189. pMalloc->Free(m_apidlOtherPlaces[i]);
  190. }
  191. }
  192. }
  193. ZeroMemory(m_apidlOtherPlaces, sizeof(m_apidlOtherPlaces));
  194. return S_OK;
  195. }
  196. STDMETHODIMP CNCWebView::OnGetWebViewLayout(DWORD pv, UINT uViewMode, SFVM_WEBVIEW_LAYOUT_DATA* pData)
  197. {
  198. ZeroMemory(pData, sizeof(*pData));
  199. pData->dwLayout = SFVMWVL_NORMAL | SFVMWVL_DETAILS;
  200. return S_OK;
  201. }
  202. STDMETHODIMP CNCWebView::OnGetWebViewTasks(DWORD pv, SFVM_WEBVIEW_TASKSECTION_DATA* pTasks)
  203. {
  204. TraceFileFunc(ttidShellViewMsgs);
  205. HRESULT hr = S_OK;
  206. ZeroMemory(pTasks, sizeof(*pTasks));
  207. CComPtr<IUnknown> pUnk;
  208. hr = reinterpret_cast<LPSHELLFOLDER>(m_pConnectionFolder)->QueryInterface(IID_IUnknown, reinterpret_cast<LPVOID *>(&pUnk));
  209. if (SUCCEEDED(hr))
  210. {
  211. if (FAILED(hr = Create_IEnumUICommand(pUnk, c_ConnFolderItemTaskList, celems(c_ConnFolderItemTaskList), &pTasks->penumFolderTasks)) ||
  212. FAILED(hr = Create_IEnumUICommand(pUnk, c_ConnFolderGlobalTaskList, celems(c_ConnFolderGlobalTaskList), &pTasks->penumSpecialTasks)) )
  213. {
  214. // something has failed - cleanup
  215. IUnknown_SafeReleaseAndNullPtr(pTasks->penumFolderTasks);
  216. IUnknown_SafeReleaseAndNullPtr(pTasks->penumSpecialTasks);
  217. }
  218. }
  219. Assert(S_OK == hr);
  220. TraceHr(ttidError, FAL, hr, FALSE, "HrOnGetWebViewTasks");
  221. return hr;
  222. }
  223. STDMETHODIMP CNCWebView::OnGetWebViewContent(DWORD pv, SFVM_WEBVIEW_CONTENT_DATA* pData)
  224. {
  225. TraceFileFunc(ttidShellViewMsgs);
  226. HRESULT hr = S_OK;
  227. ZeroMemory(pData, sizeof(*pData));
  228. DWORD dwCountOtherPlaces;
  229. hr = CreateOtherPlaces(&dwCountOtherPlaces);
  230. if (SUCCEEDED(hr))
  231. {
  232. hr = E_OUTOFMEMORY;
  233. LPCITEMIDLIST *papidl = reinterpret_cast<LPCITEMIDLIST*>(LocalAlloc(LPTR, sizeof(m_apidlOtherPlaces)));
  234. if (papidl)
  235. {
  236. // CEnumArray::CreateInstance is taking the ownership of the array of PIDLs passed
  237. // this function requires 2 things:
  238. //
  239. // 1. the caller should allocate the passed array with LocalAlloc
  240. // 2. the lifetime of the PIDLs passed should span the folder's lifetime
  241. //
  242. CopyMemory(papidl, &m_apidlOtherPlaces, sizeof(m_apidlOtherPlaces));
  243. hr = CEnumArray::CreateInstance(&pData->penumOtherPlaces, papidl, dwCountOtherPlaces);
  244. if (FAILED(hr))
  245. {
  246. LocalFree(papidl);
  247. }
  248. }
  249. if (FAILED(hr) ||
  250. FAILED(hr = Create_IUIElement(&c_ConnFolderGlobalTaskHeader, &pData->pSpecialTaskHeader)) ||
  251. FAILED(hr = Create_IUIElement(&c_ConnFolderItemTaskHeader, &pData->pFolderTaskHeader)) ||
  252. FAILED(hr = Create_IUIElement(&c_ConnFolderIntro, &pData->pIntroText)) )
  253. {
  254. // something has failed - cleanup
  255. DestroyOtherPlaces();
  256. IUnknown_SafeReleaseAndNullPtr(pData->pIntroText);
  257. IUnknown_SafeReleaseAndNullPtr(pData->pSpecialTaskHeader);
  258. IUnknown_SafeReleaseAndNullPtr(pData->pFolderTaskHeader);
  259. IUnknown_SafeReleaseAndNullPtr(pData->penumOtherPlaces);
  260. }
  261. }
  262. Assert(S_OK == hr);
  263. TraceHr(ttidError, FAL, hr, FALSE, "HrOnGetWebViewContent");
  264. return hr;
  265. }
  266. HRESULT CNCWebView::WebviewVerbInvoke(DWORD dwVerbID, IUnknown* pv, IShellItemArray *psiItemArray)
  267. {
  268. HRESULT hr = E_NOINTERFACE;
  269. CComPtr<IShellFolderViewCB> pShellFolderViewCB;
  270. hr = pv->QueryInterface(IID_IShellFolderViewCB, reinterpret_cast<LPVOID *>(&pShellFolderViewCB));
  271. if (SUCCEEDED(hr))
  272. {
  273. hr = pShellFolderViewCB->MessageSFVCB(DVM_INVOKECOMMAND, dwVerbID, NULL);
  274. }
  275. Assert(S_OK == hr);
  276. return hr;
  277. }
  278. HRESULT CNCWebView::WebviewVerbCanInvoke(DWORD dwVerbID, IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState, BOOL bLevel)
  279. {
  280. HRESULT hr = E_NOINTERFACE;
  281. CComPtr<IShellFolderViewCB> pShellFolderViewCB;
  282. hr = pv->QueryInterface(IID_IShellFolderViewCB, reinterpret_cast<LPVOID *>(&pShellFolderViewCB));
  283. if (SUCCEEDED(hr))
  284. {
  285. NCCS_STATE nccsState;
  286. hr = pShellFolderViewCB->MessageSFVCB(bLevel ? MYWM_QUERYINVOKECOMMAND_TOPLEVEL : MYWM_QUERYINVOKECOMMAND_ITEMLEVEL, dwVerbID, reinterpret_cast<LPARAM>(&nccsState) );
  287. if (S_OK != hr)
  288. {
  289. *puisState = UIS_HIDDEN;
  290. }
  291. else
  292. {
  293. switch (nccsState)
  294. {
  295. case NCCS_DISABLED:
  296. *puisState = UIS_DISABLED;
  297. break;
  298. case NCCS_ENABLED:
  299. *puisState = UIS_ENABLED;
  300. break;
  301. case NCCS_NOTSHOWN:
  302. *puisState = UIS_HIDDEN;
  303. break;
  304. default:
  305. AssertSz(FALSE, "Invalid value for NCCS_STATE");
  306. }
  307. }
  308. }
  309. Assert(S_OK == hr);
  310. return hr;
  311. }
  312. HRESULT CEnumArray::CreateInstance(
  313. IEnumIDList** ppv,
  314. LPCITEMIDLIST *ppidl,
  315. UINT cItems)
  316. {
  317. TraceFileFunc(ttidShellViewMsgs);
  318. HRESULT hr = E_OUTOFMEMORY;
  319. CEnumArray * pObj = NULL;
  320. pObj = new CComObject<CEnumArray>;
  321. if (pObj)
  322. {
  323. // Do the standard CComCreator::CreateInstance stuff.
  324. //
  325. pObj->SetVoid (NULL);
  326. pObj->InternalFinalConstructAddRef ();
  327. hr = pObj->FinalConstruct ();
  328. pObj->InternalFinalConstructRelease ();
  329. if (SUCCEEDED(hr))
  330. {
  331. pObj->_cRef = 1;
  332. pObj->_ppidl = ppidl; // takes ownership of ppidl!
  333. pObj->_cItems = cItems;
  334. pObj->Reset();
  335. hr = pObj->QueryInterface (IID_IEnumIDList, reinterpret_cast<LPVOID *>(ppv));
  336. }
  337. if (FAILED(hr))
  338. {
  339. delete pObj;
  340. }
  341. }
  342. TraceHr(ttidError, FAL, hr, FALSE, "CEnumArray::CreateInstance");
  343. return hr;
  344. }
  345. CEnumArray::CEnumArray()
  346. {
  347. _ppidl = NULL;
  348. }
  349. CEnumArray::~CEnumArray()
  350. {
  351. if (_ppidl)
  352. {
  353. LocalFree(_ppidl);
  354. }
  355. }
  356. STDMETHODIMP CEnumArray::Next(ULONG celt, LPITEMIDLIST *ppidl, ULONG *pceltFetched)
  357. {
  358. HRESULT hr = S_FALSE;
  359. if (_ppidl && (_ulIndex < _cItems))
  360. {
  361. *ppidl = ILClone(_ppidl[_ulIndex++]);
  362. if (ppidl)
  363. {
  364. hr = S_OK;
  365. }
  366. else
  367. {
  368. hr = E_OUTOFMEMORY;
  369. }
  370. }
  371. if (pceltFetched)
  372. {
  373. *pceltFetched = (hr == S_OK) ? 1 : 0;
  374. }
  375. return hr;
  376. }
  377. STDMETHODIMP CEnumArray::Skip(ULONG celt)
  378. {
  379. _ulIndex = min(_cItems, _ulIndex+celt);
  380. return S_OK;
  381. }
  382. STDMETHODIMP CEnumArray::Reset()
  383. {
  384. _ulIndex = 0;
  385. return S_OK;
  386. }
  387. STDMETHODIMP CEnumArray::Clone(IEnumIDList **ppenum)
  388. {
  389. // We can not clone this array, since we don't own references to the pidls
  390. *ppenum = NULL;
  391. return E_NOTIMPL;
  392. }
  393. HRESULT HrIsWebViewEnabled()
  394. {
  395. SHELLSTATE ss={0};
  396. // SSF_HIDDENFILEEXTS and SSF_SORTCOLUMNS don't work with
  397. // the SHELLFLAGSTATE struct, make sure they are off
  398. // (because the corresponding SHELLSTATE fields don't
  399. // exist in SHELLFLAGSTATE.)
  400. //
  401. DWORD dwMask = SSF_WEBVIEW;
  402. SHGetSetSettings(&ss, dwMask, FALSE);
  403. if (ss.fWebView)
  404. {
  405. return S_OK;
  406. }
  407. else
  408. {
  409. return S_FALSE;
  410. }
  411. }
  412. /*
  413. HRESULT GetCurrentCommandState(int iCommandId, UISTATE* puisState)
  414. {
  415. for (DWORD dwLoop = 0; dwLoop < g_nFolderCommandCount; dwLoop++)
  416. {
  417. if (iCommandId = g_cteFolderCommands[dwLoop].iCommandId)
  418. {
  419. if (g_cteFolderCommands[dwLoop].fCurrentlyValid)
  420. {
  421. *puisState = UIS_ENABLED;
  422. }
  423. else
  424. {
  425. *puisState = UIS_DISABLED;
  426. }
  427. return S_OK;
  428. }
  429. }
  430. Assert(FALSE);
  431. return E_FILE_NOT_FOUND;
  432. }
  433. HRESULT CNCWebView::CanShowConnect(IUnknown* pv, IDataObject* pdo, BOOL fOkToBeSlow, UISTATE* puisState)
  434. {
  435. HRESULT hr = GetCurrentCommandState(CMIDM_CONNECT, puisState);
  436. return hr;
  437. }
  438. HRESULT CNCWebView::CanShowDisconnect(IUnknown* pv, IDataObject* pdo, BOOL fOkToBeSlow, UISTATE* puisState)
  439. {
  440. CONFOLDENTRY cfe;
  441. *puisState = UIS_DISABLED;
  442. HRESULT hr = WVGetConFoldPidlFromIDataObject(pv, pdo, cfe);
  443. if (SUCCEEDED(hr))
  444. {
  445. if (((cfe.GetNetConMediaType() == NCM_PHONE) ||
  446. (cfe.GetNetConMediaType() == NCM_TUNNEL) ||
  447. (cfe.GetNetConMediaType() == NCM_PPPOE) ||
  448. (cfe.GetNetConMediaType() == NCM_ISDN) ||
  449. (cfe.GetNetConMediaType() == NCM_DIRECT) ||
  450. (cfe.GetNetConMediaType() == NCM_SHAREDACCESSHOST_RAS) ||
  451. (cfe.GetNetConMediaType() == NCM_NONE ) ) &&
  452. (!cfe.GetWizard()))
  453. {
  454. if ( (cfe.GetNetConStatus() == NCS_CONNECTED) )
  455. {
  456. *puisState = UIS_ENABLED;
  457. }
  458. }
  459. }
  460. Assert(SUCCEEDED(hr));
  461. return hr;
  462. }
  463. HRESULT CNCWebView::CanShowEnable(IUnknown* pv, IDataObject* pdo, BOOL fOkToBeSlow, UISTATE* puisState)
  464. {
  465. CONFOLDENTRY cfe;
  466. *puisState = UIS_DISABLED;
  467. HRESULT hr = WVGetConFoldPidlFromIDataObject(pv, pdo, cfe);
  468. if (SUCCEEDED(hr))
  469. {
  470. if ((cfe.GetNetConMediaType() == NCM_LAN) ||
  471. (cfe.GetNetConMediaType() == NCM_BRIDGE) ||
  472. (cfe.GetNetConMediaType() == NCM_SHAREDACCESSHOST_LAN))
  473. {
  474. if ( (cfe.GetNetConStatus() == NCS_DISCONNECTED) )
  475. {
  476. *puisState = UIS_ENABLED;
  477. }
  478. }
  479. }
  480. Assert(SUCCEEDED(hr));
  481. return hr;
  482. }
  483. HRESULT CNCWebView::CanShowDisable(IUnknown* pv, IDataObject* pdo, BOOL fOkToBeSlow, UISTATE* puisState)
  484. {
  485. CONFOLDENTRY cfe;
  486. *puisState = UIS_DISABLED;
  487. HRESULT hr = WVGetConFoldPidlFromIDataObject(pv, pdo, cfe);
  488. if (SUCCEEDED(hr))
  489. {
  490. if ((cfe.GetNetConMediaType() == NCM_LAN) ||
  491. (cfe.GetNetConMediaType() == NCM_BRIDGE) ||
  492. (cfe.GetNetConMediaType() == NCM_SHAREDACCESSHOST_LAN))
  493. {
  494. if ( (cfe.GetNetConStatus() == NCS_CONNECTED || NCS_INVALID_ADDRESS || NCS_MEDIA_DISCONNECTED) )
  495. {
  496. *puisState = UIS_ENABLED;
  497. }
  498. }
  499. }
  500. Assert(SUCCEEDED(hr));
  501. return hr;
  502. }
  503. HRESULT CNCWebView::CanShowRepair(IUnknown* pv, IDataObject* pdo, BOOL fOkToBeSlow, UISTATE* puisState)
  504. {
  505. CONFOLDENTRY cfe;
  506. *puisState = UIS_DISABLED;
  507. HRESULT hr = WVGetConFoldPidlFromIDataObject(pv, pdo, cfe);
  508. if (SUCCEEDED(hr))
  509. {
  510. if ((cfe.GetNetConMediaType() == NCM_LAN) ||
  511. (cfe.GetNetConMediaType() == NCM_BRIDGE) ||
  512. (cfe.GetNetConMediaType() == NCM_SHAREDACCESSHOST_LAN))
  513. {
  514. if ( (cfe.GetNetConStatus() == NCS_CONNECTED || NCS_INVALID_ADDRESS || NCS_MEDIA_DISCONNECTED) )
  515. {
  516. *puisState = UIS_ENABLED;
  517. }
  518. }
  519. }
  520. Assert(SUCCEEDED(hr));
  521. return S_OK;
  522. }
  523. HRESULT CNCWebView::CanShowRename(IUnknown* pv, IDataObject* pdo, BOOL fOkToBeSlow, UISTATE* puisState)
  524. {
  525. CONFOLDENTRY cfe;
  526. *puisState = UIS_DISABLED;
  527. HRESULT hr = WVGetConFoldPidlFromIDataObject(pv, pdo, cfe);
  528. if (SUCCEEDED(hr))
  529. {
  530. if ((!cfe.GetWizard()) &&
  531. !(cfe.GetCharacteristics() && NCCF_INCOMING_ONLY))
  532. {
  533. *puisState = UIS_ENABLED;
  534. }
  535. }
  536. Assert(SUCCEEDED(hr))
  537. return S_OK;
  538. }
  539. HRESULT CNCWebView::CanShowStatus(IUnknown* pv, IDataObject* pdo, BOOL fOkToBeSlow, UISTATE* puisState)
  540. {
  541. CONFOLDENTRY cfe;
  542. *puisState = UIS_DISABLED;
  543. HRESULT hr = WVGetConFoldPidlFromIDataObject(pv, pdo, cfe);
  544. if (SUCCEEDED(hr))
  545. {
  546. if ((!cfe.GetWizard()) &&
  547. (cfe.GetNetConStatus() == NCS_CONNECTED || NCS_INVALID_ADDRESS || NCS_MEDIA_DISCONNECTED) )
  548. {
  549. *puisState = UIS_ENABLED;
  550. }
  551. }
  552. Assert(SUCCEEDED(hr));
  553. return S_OK;
  554. }
  555. HRESULT CNCWebView::CanShowDelete(IUnknown* pv, IDataObject* pdo, BOOL fOkToBeSlow, UISTATE* puisState)
  556. {
  557. CONFOLDENTRY cfe;
  558. *puisState = UIS_DISABLED;
  559. HRESULT hr = WVGetConFoldPidlFromIDataObject(pv, pdo, cfe);
  560. if (SUCCEEDED(hr))
  561. {
  562. if (((cfe.GetNetConMediaType() == NCM_PHONE) ||
  563. (cfe.GetNetConMediaType() == NCM_TUNNEL) ||
  564. (cfe.GetNetConMediaType() == NCM_PPPOE) ||
  565. (cfe.GetNetConMediaType() == NCM_ISDN) ||
  566. (cfe.GetNetConMediaType() == NCM_DIRECT) ||
  567. (cfe.GetNetConMediaType() == NCM_SHAREDACCESSHOST_RAS) ||
  568. (cfe.GetNetConMediaType() == NCM_NONE ) ) &&
  569. (!cfe.GetWizard()))
  570. {
  571. *puisState = UIS_ENABLED;
  572. }
  573. }
  574. Assert(SUCCEEDED(hr));
  575. return S_OK;
  576. }
  577. HRESULT CNCWebView::CanShowHomenet(IUnknown* pv, IDataObject* pdo, BOOL fOkToBeSlow, UISTATE* puisState)
  578. {
  579. *puisState = UIS_ENABLED;
  580. return S_OK;
  581. }
  582. */