/**********************************************************************/ /** Microsoft Windows/NT **/ /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/ /**********************************************************************/ /* basertr.cpp Base Router handler implementation. FILE HISTORY: */ #include "stdafx.h" #include "util.h" #include "basertr.h" #include "basecon.h" #include "tfschar.h" #include "strmap.h" // XXXtoCString functions #include "service.h" // TFS service APIs #include "rtrstr.h" // const strings used #include "rtrsheet.h" // RtrPropertySheet #include "rtrutil.h" /*--------------------------------------------------------------------------- BaseRouterHandler implementation ---------------------------------------------------------------------------*/ BaseRouterHandler::BaseRouterHandler(ITFSComponentData *pCompData) : CHandler(pCompData), m_nHelpTopicId(IDS_DEFAULT_HELP_TOPIC) { // Initialize all of the buttons to be hidden by default for (int i=0; iGetNodeType(); CString strProviderId, strGuid; StringFromGUID2(*pGuid, strGuid.GetBuffer(256), 256); strGuid.ReleaseBuffer(); // RouterInfo should be available now Assert(m_spRouterInfo); DWORD RouterInfoFlags = m_spRouterInfo->GetFlags(); // if the machine is added not as local, then we use the machine name if (0 == (RouterInfoFlags & RouterInfo_AddedAsLocal)) // not added as local strId = m_spRouterInfo->GetMachineName() + strGuid; else strId = strGuid; return hrOK; } /*!-------------------------------------------------------------------------- BaseRouterHandler::OnResultSelect - Author: KennT ---------------------------------------------------------------------------*/ HRESULT BaseRouterHandler::OnResultSelect(ITFSComponent *pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam) { SPIConsoleVerb spConsoleVerb; SPITFSNode spNode; HRESULT hr = hrOK; CORg( pComponent->GetConsoleVerb(&spConsoleVerb) ); CORg( m_spNodeMgr->FindNode(cookie, &spNode) ); // If you need to update the verb state, do it here EnableVerbs(spConsoleVerb); Error: return hr; } /*!-------------------------------------------------------------------------- BaseRouterHandler::EnableVerbs - Author: KennT ---------------------------------------------------------------------------*/ void BaseRouterHandler::EnableVerbs(IConsoleVerb *pConsoleVerb) { Assert(pConsoleVerb); Assert(DimensionOf(m_rgButtonState) == DimensionOf(m_bState)); Assert(DimensionOf(m_rgButtonState) == MMC_VERB_COUNT); for (int i=0; iSetVerbState(INDEX_TO_VERB(i), HIDDEN, TRUE); } else { // unhide this button before enabling pConsoleVerb->SetVerbState(INDEX_TO_VERB(i), HIDDEN, FALSE); pConsoleVerb->SetVerbState(INDEX_TO_VERB(i), ENABLED, m_bState[i]); } } pConsoleVerb->SetDefaultVerb(m_verbDefault); } /*!-------------------------------------------------------------------------- BaseRouterHandler::OnResultPropertyChange - Author: KennT ---------------------------------------------------------------------------*/ HRESULT BaseRouterHandler::OnResultPropertyChange ( ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM param ) { AFX_MANAGE_STATE(AfxGetStaticModuleState( )); SPITFSNode spNode; m_spNodeMgr->FindNode(cookie, &spNode); RtrPropertySheet * pPropSheet = reinterpret_cast(param); LONG_PTR changeMask = 0; // tell the property page to do whatever now that we are back on the // main thread pPropSheet->OnPropertyChange(TRUE, &changeMask); pPropSheet->AcknowledgeNotify(); if (changeMask) spNode->ChangeNode(changeMask); return hrOK; } /*!-------------------------------------------------------------------------- BaseRouterHandler::OnPropertyChange - Author: KennT ---------------------------------------------------------------------------*/ HRESULT BaseRouterHandler::OnPropertyChange ( ITFSNode *pNode, LPDATAOBJECT pDataObject, DWORD dwType, LPARAM arg, LPARAM param ) { // This is running on the MAIN THREAD! // ---------------------------------------------------------------- AFX_MANAGE_STATE(AfxGetStaticModuleState( )); RtrPropertySheet * pPropSheet = reinterpret_cast(param); LONG_PTR changeMask = 0; // tell the property page to do whatever now that we are back on the // main thread pPropSheet->OnPropertyChange(TRUE, &changeMask); pPropSheet->AcknowledgeNotify(); if (changeMask) pNode->ChangeNode(changeMask); return hrOK; } /*!-------------------------------------------------------------------------- BaseRouterHandler::OnVerbRefresh - Author: KennT ---------------------------------------------------------------------------*/ HRESULT BaseRouterHandler::OnVerbRefresh(ITFSNode *pNode, LPARAM arg, LPARAM lParam) { return ForceGlobalRefresh(m_spRouterInfo); } /*!-------------------------------------------------------------------------- BaseRouterHandler::OnResultRefresh - Author: KennT ---------------------------------------------------------------------------*/ HRESULT BaseRouterHandler::OnResultRefresh(ITFSComponent *pTFSComponent, LPDATAOBJECT lpDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam) { return ForceGlobalRefresh(m_spRouterInfo); } HRESULT BaseRouterHandler::ForwardCommandToParent(ITFSNode *pNode, long nCommandId, DATA_OBJECT_TYPES type, LPDATAOBJECT pDataObject, DWORD dwType) { SPITFSNode spParent; SPITFSNodeHandler spHandler; HRESULT hr = hrOK; CORg( pNode->GetParent(&spParent) ); if (!spParent) CORg( E_INVALIDARG ); CORg( spParent->GetHandler(&spHandler) ); if (!spHandler) CORg( E_INVALIDARG ); hr = spHandler->OnCommand(spParent, nCommandId, type, pDataObject, dwType); Error: return hr; } /*!-------------------------------------------------------------------------- BaseRouterHandler::EnumDynamicExtensions Author: KennT ---------------------------------------------------------------------------*/ HRESULT BaseRouterHandler::EnumDynamicExtensions(ITFSNode * pNode) { HRESULT hr = hrOK; CORg (m_dynExtensions.SetNode(pNode->GetNodeType())); CORg (m_dynExtensions.Reset()); CORg (m_dynExtensions.Load()); Error: return hr; } /*!-------------------------------------------------------------------------- BaseRouterHandler::EnumDynamicExtensions Author: KennT ---------------------------------------------------------------------------*/ HRESULT BaseRouterHandler::AddDynamicNamespaceExtensions(ITFSNode * pNode) { HRESULT hr = hrOK; CGUIDArray aNamespace; SPIConsoleNameSpace spNS; int i; COM_PROTECT_TRY { // enumerate dynamic namespace extensions CORg (m_spNodeMgr->GetConsoleNameSpace(&spNS)); m_dynExtensions.GetNamespaceExtensions(aNamespace); for (i = 0; i < aNamespace.GetSize(); i++) { HRESULT hrAdd = spNS->AddExtension(pNode->GetData(TFS_DATA_SCOPEID), &aNamespace[i]); if (FAILED(hrAdd)) Trace1("BaseRouterHandler::AddDynamicNamespaceExtensions - AddExtension failed %x", hrAdd); } COM_PROTECT_ERROR_LABEL; } COM_PROTECT_CATCH return hr; } /*!-------------------------------------------------------------------------- BaseRouterHandler::OnResultContextHelp - Author: MikeG (a-migall) ---------------------------------------------------------------------------*/ HRESULT BaseRouterHandler::OnResultContextHelp(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam) { // Not used... UNREFERENCED_PARAMETER(pDataObject); UNREFERENCED_PARAMETER(cookie); UNREFERENCED_PARAMETER(arg); UNREFERENCED_PARAMETER(lParam); AFX_MANAGE_STATE(AfxGetStaticModuleState()); return HrDisplayHelp(pComponent, m_spTFSCompData->GetHTMLHelpFileName(), m_nHelpTopicId); } /*!-------------------------------------------------------------------------- BaseRouterHandler::AddArrayOfMenuItems - Author: KennT ---------------------------------------------------------------------------*/ HRESULT BaseRouterHandler::AddArrayOfMenuItems(ITFSNode *pNode, const SRouterNodeMenu *prgMenu, UINT crgMenu, LPCONTEXTMENUCALLBACK pCallback, long iInsertionAllowed, INT_PTR pUserData) { HRESULT hr = hrOK; ULONG ulFlags; UINT i; CString stMenu; // Now go through and add our menu items for (i=0; i