void FxInternal::EffectUnload() { HRESULT hr= S_OK; MStatus status= MStatus::kSuccess; MFnDependencyNode depNode(GetSite()); DXCC_RELEASE(Effect); MPlug scriptPlug(GetSite(), DirectXShader::aScript); if(!scriptPlug.isNull()) DXCHECK_MSTATUS(scriptPlug.setValue("")); MObject root = depNode.attribute(DirectXShader::RootShortName); if(!root.isNull()) depNode.removeAttribute(root); }
EditorIntroAdapterPart::~EditorIntroAdapterPart() { //setBarVisibility(true); if(introPart) { introPart->RemovePropertyListener(propChangeListener); GetSite()->GetWorkbenchWindow()->GetWorkbench()->GetIntroManager()->CloseIntro( introPart); } }
/** * Error * * Called when an error occurred for the connection. * * @param ErrorCode error code */ void CIRCConnection::Error(int ErrorValue) { char *ErrorMsg = NULL; if (ErrorValue != -1) { #ifdef _WIN32 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, ErrorValue, 0, (char *)&ErrorMsg, 0, NULL); #else if (ErrorValue != 0) { ErrorMsg = strerror(ErrorValue); } #endif } if (GetOwner() != NULL) { if (ErrorMsg == NULL || ErrorMsg[0] == '\0') { if (GetCurrentNick() != NULL && GetSite() != NULL) { g_Bouncer->LogUser(GetOwner(), "User '%s' [%s!%s] was disconnected " "from the IRC server.", GetOwner()->GetUsername(), GetCurrentNick(), GetSite()); } else { g_Bouncer->LogUser(GetOwner(), "User '%s' was disconnected " "from the IRC server.", GetOwner()->GetUsername()); } } else { if (GetCurrentNick() != NULL && GetSite() != NULL) { g_Bouncer->LogUser(GetOwner(), "User '%s' [%s!%s] was disconnected " "from the IRC server: %s", GetOwner()->GetUsername(), GetCurrentNick(), GetSite(), ErrorMsg); } else { g_Bouncer->LogUser(GetOwner(), "User '%s' was disconnected " "from the IRC server: %s", GetOwner()->GetUsername(), ErrorMsg); } } } #ifdef _WIN32 if (ErrorMsg != NULL) { LocalFree(ErrorMsg); } #endif }
BOOL fsSitesMgr::SaveToFile(HANDLE hFile) { vmsAUTOLOCKSECTION (m_csSites); int cPermSites = GetSiteCount () - GetTempSiteCount (); DWORD dw; fsSitesFileHdr hdr; if (!WriteFile (hFile, &hdr, sizeof (hdr), &dw, NULL)) return FALSE; if (!WriteFile (hFile, &cPermSites, sizeof (cPermSites), &dw, NULL)) return FALSE; BOOL bMaySavePwds = _App.SM_KeepPasswords () && _App.SM_DontSavePwdsToDisk () == FALSE; for (int i = 0; i < GetSiteCount (); i++) { fsSiteInfo *site = GetSite (i); if (site->bTemp) continue; if (!fsSaveStrToFile (site->strName, hFile)) return FALSE; if (!fsSaveStrToFile (bMaySavePwds ? site->strPassword : NULL, hFile)) return FALSE; if (!fsSaveStrToFile (bMaySavePwds ? site->strUser : NULL, hFile)) return FALSE; UINT nGrpId = site->pGroup ? site->pGroup->nId : (UINT)-1; if (!WriteFile (hFile, &nGrpId, sizeof (UINT), &dw, NULL)) return FALSE; if (!WriteFile (hFile, &site->dwFtpFlags, sizeof (site->dwFtpFlags), &dw, NULL)) return FALSE; if (!WriteFile (hFile, &site->cConnsNow, sizeof (site->cConnsNow), &dw, NULL)) return FALSE; if (!WriteFile (hFile, &site->cMaxConns, sizeof (site->cMaxConns), &dw, NULL)) return FALSE; if (!WriteFile (hFile, &site->dwValidFor, sizeof (site->dwValidFor), &dw, NULL)) return FALSE; } return TRUE; }
ConnectInfo *ServerInfo::GetConnInfo(Server_type type,char *pName) { if (!pName) { return NULL; } SiteInfo *pSite = GetSite(type); if (pSite) { return pSite->Find(pName); } return NULL; }
STDMETHODIMP CEstEIDIEPluginBHO::SetSite(IUnknown* pUnkSite) { EstEID_log(""); IObjectWithSiteImpl<CEstEIDIEPluginBHO>::SetSite(pUnkSite); CComPtr<IServiceProvider> pSP; HRESULT hr = GetSite(IID_IServiceProvider, reinterpret_cast<LPVOID *>(&pSP)); if(S_OK != hr) { return hr; } hr = pSP->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, reinterpret_cast<LPVOID *>(&webBrowser)); return S_OK; }
ConnectInfo *ServerInfo::GetDefult(Server_type type) { SiteInfo *pSite = GetSite(type); if (pSite) { ConnectInfo *pConn = pSite->m_pDefault; if (!pConn) { pConn = pSite->m_ayConn.GetAt(0); } return pConn; } return NULL; }
void QmitkMatchPoint::CreateQtPartControl(QWidget* parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); m_Parent = parent; m_Controls.m_tabs->setCurrentIndex(0); m_Controls.movingNodeSelector->SetDataStorage(this->GetDataStorage()); m_Controls.movingNodeSelector->SetSelectionIsOptional(false); m_Controls.targetNodeSelector->SetDataStorage(this->GetDataStorage()); m_Controls.targetNodeSelector->SetSelectionIsOptional(false); m_Controls.movingMaskNodeSelector->SetDataStorage(this->GetDataStorage()); m_Controls.movingMaskNodeSelector->SetSelectionIsOptional(true); m_Controls.targetMaskNodeSelector->SetDataStorage(this->GetDataStorage()); m_Controls.targetMaskNodeSelector->SetSelectionIsOptional(true); m_AlgorithmSelectionListener.reset(new berry::SelectionChangedAdapter<QmitkMatchPoint>(this, &QmitkMatchPoint::OnAlgorithmSelectionChanged)); // register selection listener GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddSelectionListener( m_AlgorithmSelectionListener.data()); this->CreateConnections(); this->AdaptFolderGUIElements(); this->CheckInputs(); this->ConfigureProgressInfos(); this->ConfigureRegistrationControls(); this->ConfigureNodeSelectors(); berry::ISelection::ConstPointer selection = GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.matchpoint.algorithm.browser"); this->UpdateAlgorithmSelection(selection); }
MPlug FxInternal::GetValuePlug(MPlug& plug) { MFnDependencyNode depNode(GetSite()); MObject oAttribute = plug.attribute(); MFnAttribute fnAttribute(oAttribute); MString name = fnAttribute.name() + MString("Value"); oAttribute= depNode.attribute(name); return plug.child(oAttribute); }
void QmitkXnatEditor::UpdateSession(ctkXnatSession* session) { GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemoveSelectionListener(m_SelectionListener.data()); if (session != 0 && session->isOpen()) { m_Controls.labelInfo->setText("Current Position:"); m_Controls.labelInfo->setStyleSheet("QLabel { color: black; }"); // Fill model and show in the GUI QmitkXnatObjectEditorInput::Pointer xoPtr(new QmitkXnatObjectEditorInput(session->dataModel())); berry::IEditorInput::Pointer editorInput(xoPtr); this->SetInput(editorInput); this->GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->GetXnatObject()->fetch(); UpdateList(); } else { m_Controls.labelInfo->setText("Please check the Preferences of the XNAT Connection.\nMaybe they are not ok."); m_Controls.labelInfo->setStyleSheet("QLabel { color: red; }"); } GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddSelectionListener(m_SelectionListener.data()); }
///////////////////////////////////////////////////////////////////////////// // IPropertyAction methods STDMETHODIMP CTextSearchEngine::AddConfigPages (LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam, LPCSTR pcDesc, UINT *puiCnt) { char cbCaption[128]; try { if (NULL != pcDesc) // Caption ist gegeben strcpy (cbCaption, pcDesc); else // von zugehöriger ClassProperty unseren Namen besorgen GetPropInfo (cbCaption, sizeof(cbCaption), NULL); // Kontext des Dialoges feststellen WClassProperty Cls; bool fChoice = false; if (SUCCEEDED(GetSite (IID_IClassProperty, Cls.ppv()))) { // Kontext ist entweder PropertyChoice oder PropertySequence DWORD dwFlags = 0; if (SUCCEEDED(Cls -> GetPropInfo (NULL, 0, &dwFlags))) fChoice = (dwFlags & PROPCAPS_CONTAINER_IS_CHOICE) ? true : false; } // zugehörigen ConfigDialog (PropertyPage(s)) anlegen ResourceFile RF (g_pDLLName); UINT uiRes = fChoice ? IDD_TEXTSEARCHENGINE_CFGPP : IDD_TEXTSEARCHENGINE_CFG; DELETE_OBJ(m_pCfgDlg); // evtl. vorherigen freigeben m_pCfgDlg = CCfgTextSearch::CreateInstance (this, ResID (uiRes, &RF), cbCaption); if (NULL == m_pCfgDlg) _com_issue_error(E_OUTOFMEMORY); HPROPSHEETPAGE hPSP = this -> CreatePage(m_pCfgDlg); if (NULL == hPSP || !lpfnAddPage(hPSP, lParam)) _com_issue_error(E_UNEXPECTED); if (puiCnt) *puiCnt = 1; m_pCfgDlg -> InitWithData (m_Status); } catch (_com_error& hr_result) { DELETE_OBJ (m_pCfgDlg); if (puiCnt) *puiCnt = 0; return _COM_ERROR(hr_result); } return S_OK; }
QmitkDataManagerView::~QmitkDataManagerView() { berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); if(s) s->RemoveSelectionListener(m_SelectionListener); berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById<berry::IPreferencesService>(berry::IPreferencesService::ID); berry::IBerryPreferences::Pointer prefs = (prefService->GetSystemPreferences()->Node(VIEW_ID)) .Cast<berry::IBerryPreferences>(); prefs->OnChanged.RemoveListener( berry::MessageDelegate1<QmitkDataManagerView , const berry::IBerryPreferences*>( this , &QmitkDataManagerView::OnPreferencesChanged ) ); }
VALUE CRScriptCore::GetOleObject(VALUE self, LPCOLESTR pstrName) { ItemMapIter it = m_mapItem.find(pstrName); if (it == m_mapItem.end()) { it = (m_mapItem.insert(ItemMap::value_type(pstrName, new CItemHolder))).first; } VALUE obj = Qnil; IDispatch* pDisp = NULL; IActiveScriptSite* pSite = GetSite(); if (pSite) { pDisp = (*it).second->GetDispatch(pSite, const_cast<LPOLESTR>(pstrName), (m_dwThreadID == GetCurrentThreadId())); pSite->Release(); } if (pDisp) { oledataex *pole; // setting free function is not required. because ScriptEngine hold it. obj = Data_Make_Struct(self, oledataex, 0, 0, pole); #ifdef __IRubyWrapper_INTERFACE_DEFINED__ IDispatchEx* pEx; if (QueryInterface(IID_IRubyEngine, (void**)&pole->pEngine) == S_OK) { // adjust ref count (because never release the ptr in WIN32OLEEX) pole->pEngine->Release(); } if (pDisp->QueryInterface(IID_IDispatchEx, (void**)&pEx) == S_OK) { pole->pDispatch = pEx; pole->pServiceProvider = this; pDisp->Release(); } else #endif { pole->pDispatch = pDisp; } ATLTRACE(_T("add OLE Object into list:%08X\n"), pole); m_listOleObj.push_back(reinterpret_cast<oledata*>(pole)); } return obj; }
void ServerInfo::AddConn(Server_type type,ConnectInfo *conn,BOOL bdefault) { if (!conn) { return; } SiteInfo *pSite = GetSite(type); if (!pSite) { pSite = new SiteInfo; m_aySites.Add(pSite); pSite->m_cType = type; } ConnectInfo *pConn = new ConnectInfo; pConn->Copy(conn); pSite->m_ayConn.Add(pConn); if (bdefault) { pSite->m_pDefault = pConn; } }
HWND CXMLHttpRequest::GetParentWindow() { HWND hWnd = GetDesktopWindow(); CComPtr<IServiceProvider> pSP; HRESULT hr = GetSite(IID_IServiceProvider, reinterpret_cast<LPVOID *> (&pSP)); if (S_OK != hr) return hWnd; CComPtr<IWebBrowser2> pWB; hr = pSP->QueryService(SID_SWebBrowserApp,IID_IWebBrowser2, reinterpret_cast<LPVOID *> (&pWB)); if (S_OK != hr) return hWnd; long lWnd = 0; hr = pWB->get_HWND(&lWnd); if (S_OK != hr) return hWnd; return reinterpret_cast<HWND> (lWnd); }
void QmitkSemanticRelationsView::CreateQtPartControl(QWidget* parent) { // create GUI widgets m_Controls.setupUi(parent); m_LesionInfoWidget = new QmitkLesionInfoWidget(GetDataStorage(), parent); m_Controls.gridLayout->addWidget(m_LesionInfoWidget); m_PatientTableInspector = new QmitkPatientTableInspector(parent); m_PatientTableInspector->SetDataStorage(GetDataStorage()); m_Controls.gridLayout->addWidget(m_PatientTableInspector); QGridLayout* dndDataNodeWidgetLayout = new QGridLayout; dndDataNodeWidgetLayout->addWidget(m_PatientTableInspector, 0, 0); dndDataNodeWidgetLayout->setContentsMargins(0, 0, 0, 0); m_DnDDataNodeWidget = new QmitkDnDDataNodeWidget(parent); m_DnDDataNodeWidget->setLayout(dndDataNodeWidgetLayout); m_Controls.gridLayout->addWidget(m_DnDDataNodeWidget); m_ContextMenu = new QmitkSemanticRelationsContextMenu(GetSite(), m_PatientTableInspector); m_ContextMenu->SetDataStorage(GetDataStorage()); mitk::IRenderWindowPart* renderWindowPart = GetRenderWindowPart(); if (nullptr != renderWindowPart) { RenderWindowPartActivated(renderWindowPart); } SetUpConnections(); const auto& allCaseIDs = mitk::RelationStorage::GetAllCaseIDs(); for (const auto& caseID : allCaseIDs) { AddToComboBox(caseID); } }
/** * Saves a rendering of the current site by its host container as a PNG file. * This implementation is derived from IECapt. * * @param outputFile the file to save the PNG output as * @link http://iecapt.sourceforge.net/ */ STDMETHODIMP CCoSnapsie::saveSnapshot( BSTR outputFile, BSTR frameId, LONG drawableScrollWidth, LONG drawableScrollHeight, LONG drawableClientWidth, LONG drawableClientHeight, LONG drawableClientLeft, LONG drawableClientTop, LONG frameBCRLeft, LONG frameBCRTop) { HRESULT hr; HWND hwndBrowser; CComPtr<IOleClientSite> spClientSite; CComQIPtr<IServiceProvider> spISP; CComPtr<IWebBrowser2> spBrowser; CComPtr<IDispatch> spDispatch; CComQIPtr<IHTMLDocument2> spDocument; CComPtr<IHTMLWindow2> spScrollableWindow; CComQIPtr<IViewObject2> spViewObject; CComPtr<IHTMLStyle> spStyle; CComQIPtr<IHTMLElement2> spScrollableElement; CComVariant documentHeight; CComVariant documentWidth; CComVariant viewportHeight; CComVariant viewportWidth; GetSite(IID_IUnknown, (void**)&spClientSite); if (spClientSite == NULL) { Error(L"There is no site."); return E_FAIL; } spISP = spClientSite; if (spISP == NULL) { Error(L"Unable to convert client site to service provider."); return E_FAIL; } // from http://support.microsoft.com/kb/257717 hr = spISP->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, (void **)&spBrowser); if (FAILED(hr)) { // if we can't query the client site for IWebBrowser2, we're probably // in an HTA. Obtain the IHTMLWindow2 interface pointer by directly // querying the client site's service provider. // http://groups.google.com/group/microsoft.public.vc.language/browse_thread/thread/f8987a31d47cccfe/884cb8f13423039e CComPtr<IHTMLWindow2> spWindow; hr = spISP->QueryService(IID_IHTMLWindow2, &spWindow); if (FAILED(hr)) { Error("Failed to obtain IHTMLWindow2 from service provider"); return E_FAIL; } hr = spWindow->get_document(&spDocument); if (FAILED(hr)) { Error("Failed to obtain IHTMLDocument2 from window"); return E_FAIL; } CComQIPtr<IOleWindow> spOleWindow = spDocument; if (spOleWindow == NULL) { Error("Failed to obtain IOleWindow from document"); return E_FAIL; } hr = spOleWindow->GetWindow(&hwndBrowser); if (FAILED(hr)) { Error("Failed to obtain HWND from OLE window"); return E_FAIL; } hwndBrowser = GetAncestor(hwndBrowser, GA_ROOTOWNER); } else { hr = spBrowser->get_HWND((long*)&hwndBrowser); if (FAILED(hr)) { Error("Failed to get HWND for browser (is this a frame?)"); return E_FAIL; } ie = GetAncestor(hwndBrowser, GA_ROOTOWNER); CComPtr<IDispatch> spDispatch; hr = spBrowser->get_Document(&spDispatch); if (FAILED(hr)) return E_FAIL; spDocument = spDispatch; if (spDocument == NULL) return E_FAIL; IServiceProvider* pServiceProvider = NULL; if (SUCCEEDED(spBrowser->QueryInterface( IID_IServiceProvider, (void**)&pServiceProvider))) { IOleWindow* pWindow = NULL; if (SUCCEEDED(pServiceProvider->QueryService( SID_SShellBrowser, IID_IOleWindow, (void**)&pWindow))) { if (SUCCEEDED(pWindow->GetWindow(&hwndBrowser))) { hwndBrowser = FindWindowEx(hwndBrowser, NULL, _T("Shell DocObject View"), NULL); if (hwndBrowser) { hwndBrowser = FindWindowEx(hwndBrowser, NULL, _T("Internet Explorer_Server"), NULL); } } pWindow->Release(); } pServiceProvider->Release(); } } // Nobody else seems to know how to get IViewObject2?! // http://starkravingfinkle.org/blog/2004/09/ spViewObject = spDocument; if (spViewObject == NULL) { Error(L"Unable to convert document to view object."); return E_FAIL; } CComQIPtr<IHTMLDocument5> spDocument5; spDocument->QueryInterface(IID_IHTMLDocument5, (void**)&spDocument5); if (spDocument5 == NULL) { Error(L"Snapsie requires IE6 or greater."); return E_FAIL; } CComBSTR compatMode; spDocument5->get_compatMode(&compatMode); // In non-standards-compliant mode, the BODY element represents the canvas. if (compatMode == L"BackCompat") { CComPtr<IHTMLElement> spBody; spDocument->get_body(&spBody); if (NULL == spBody) { return E_FAIL; } spBody->getAttribute(CComBSTR("scrollHeight"), 0, &documentHeight); spBody->getAttribute(CComBSTR("scrollWidth"), 0, &documentWidth); spBody->getAttribute(CComBSTR("clientHeight"), 0, &viewportHeight); spBody->getAttribute(CComBSTR("clientWidth"), 0, &viewportWidth); } // In standards-compliant mode, the HTML element represents the canvas. else { CComQIPtr<IHTMLDocument3> spDocument3; spDocument->QueryInterface(IID_IHTMLDocument3, (void**)&spDocument3); if (NULL == spDocument3) { Error(L"Unable to get IHTMLDocument3 handle from document."); return E_FAIL; } // The root node should be the HTML element. CComPtr<IHTMLElement> spRootNode; spDocument3->get_documentElement(&spRootNode); if (NULL == spRootNode) { Error(L"Could not retrieve root node."); return E_FAIL; } CComPtr<IHTMLHtmlElement> spHtml; spRootNode->QueryInterface(IID_IHTMLHtmlElement, (void**)&spHtml); if (NULL == spHtml) { Error(L"Root node is not the HTML element."); return E_FAIL; } spRootNode->getAttribute(CComBSTR("scrollHeight"), 0, &documentHeight); spRootNode->getAttribute(CComBSTR("scrollWidth"), 0, &documentWidth); spRootNode->getAttribute(CComBSTR("clientHeight"), 0, &viewportHeight); spRootNode->getAttribute(CComBSTR("clientWidth"), 0, &viewportWidth); } // Figure out how large to make the window. It's not sufficient to just use the dimensions of the scrolled // viewport because the browser chrome occupies space that must be accounted for as well. RECT ieWindowRect; GetWindowRect(ie, &ieWindowRect); int ieWindowWidth = ieWindowRect.right - ieWindowRect.left; int ieWindowHeight = ieWindowRect.bottom - ieWindowRect.top; RECT contentClientRect; GetClientRect(hwndBrowser, &contentClientRect); int contentClientWidth = contentClientRect.right - contentClientRect.left; int contentClientHeight = contentClientRect.bottom - contentClientRect.top; int chromeWidth = ieWindowWidth - contentClientWidth; int chromeHeight = 2 * (ieWindowHeight - contentClientHeight); int imageHeight = documentHeight.intVal; int imageWidth = documentWidth.intVal; maxWidth = imageWidth + chromeWidth; maxHeight = imageHeight + chromeHeight; long originalHeight, originalWidth; spBrowser->get_Height(&originalHeight); spBrowser->get_Width(&originalWidth); // The resize message is being ignored if the window appears to be maximized. There's likely a // way to bypass that. My ghetto way is to unmaximize the window, then move on with setting // the window to the dimensions we really want. This is okay because we revert back to the // original dimensions afterward. BOOL isMaximized = IsZoomed(ie); if (isMaximized) { ShowWindow(ie, SW_SHOWNORMAL); } // Get the path to this DLL so we can load it up with LoadLibrary. TCHAR dllPath[_MAX_PATH]; GetModuleFileName((HINSTANCE) &__ImageBase, dllPath, _MAX_PATH); // Get the path to the Windows hook we use to allow resizing the window greater than the virtual screen resolution. HINSTANCE hinstDLL = LoadLibrary(dllPath); HOOKPROC hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL, "CallWndProc"); if (hkprcSysMsg == NULL) PrintError(L"GetProcAddress"); // Install the Windows hook. nextHook = SetWindowsHookEx(WH_CALLWNDPROC, hkprcSysMsg, hinstDLL, 0); if (nextHook == 0) PrintError(L"SetWindowsHookEx"); spBrowser->put_Height(maxHeight); spBrowser->put_Width(maxWidth); // Capture the window's canvas to a DIB. CImage image; image.Create(imageWidth, imageHeight, 24); CImageDC imageDC(image); hr = PrintWindow(hwndBrowser, imageDC, PW_CLIENTONLY); if (FAILED(hr)) { Error(L"PrintWindow"); } // I'm not sure if PrintWindow captures alpha blending or not. OleDraw does, but I was having // issues with sizing the browser correctly between quirks and standards modes to capture everything we need. // //RECT rcBounds = { 0, 0, imageWidth, imageHeight }; //hr = OleDraw(spViewObject, DVASPECT_DOCPRINT, imageDC, &rcBounds); //if (FAILED(hr)) //{ // Error(L"OleDraw"); //} UnhookWindowsHookEx(nextHook); // Restore the browser to the original dimensions. if (isMaximized) { ShowWindow(ie, SW_MAXIMIZE); } else { spBrowser->put_Height(originalHeight); spBrowser->put_Width(originalWidth); } hr = image.Save(CW2T(outputFile)); if (FAILED(hr)) { PrintError(L"Failed saving image."); return E_FAIL; } return hr; }
/** * ParseLineArgV * * Parses and processes a line which was sent by the server. * * @param argc number of tokens * @param argv the tokens */ bool CIRCConnection::ParseLineArgV(int argc, const char **argv) { CChannel *Channel; CClientConnection *Client; m_LastResponse = g_CurrentTime; if (argc < 2) { return true; } const char *Reply = argv[0]; const char *Raw = argv[1]; char *Nick = ::NickFromHostmask(Reply); int iRaw = atoi(Raw); bool b_Me = false; if (m_CurrentNick != NULL && Nick != NULL && strcasecmp(Nick, m_CurrentNick) == 0) { b_Me = true; } free(Nick); Client = GetOwner()->GetClientConnectionMultiplexer(); // HASH values CHashCompare hashRaw(argv[1]); static CHashCompare hashPrivmsg("PRIVMSG"); static CHashCompare hashNotice("NOTICE"); static CHashCompare hashJoin("JOIN"); static CHashCompare hashPart("PART"); static CHashCompare hashKick("KICK"); static CHashCompare hashNick("NICK"); static CHashCompare hashQuit("QUIT"); static CHashCompare hashMode("MODE"); static CHashCompare hashTopic("TOPIC"); static CHashCompare hashPong("PONG"); // END of HASH values if (argc > 3 && iRaw == 433) { bool ReturnValue = ModuleEvent(argc, argv); if (ReturnValue) { if (GetCurrentNick() == NULL) { WriteLine("NICK :%s_", argv[3]); } if (m_NickCatchTimer == NULL) { m_NickCatchTimer = new CTimer(30, false, NickCatchTimer, this); } } return ReturnValue; } else if (argc > 3 && hashRaw == hashPrivmsg && Client == NULL) { const char *Host; const char *Dest = argv[2]; char *Nick = ::NickFromHostmask(Reply); Channel = GetChannel(Dest); if (Channel != NULL) { CNick *User = Channel->GetNames()->Get(Nick); if (User != NULL) { User->SetIdleSince(g_CurrentTime); } Channel->AddBacklogLine(argv[0], argv[3]); } if (!ModuleEvent(argc, argv)) { free(Nick); return false; } /* don't log ctcp requests */ if (argv[3][0] != '\1' && argv[3][strlen(argv[3]) - 1] != '\1' && Dest != NULL && Nick != NULL && m_CurrentNick != NULL && strcasecmp(Dest, m_CurrentNick) == 0 && strcasecmp(Nick, m_CurrentNick) != 0) { char *Dup; char *Delim; Dup = strdup(Reply); if (AllocFailed(Dup)) { free(Nick); return true; } Delim = strchr(Dup, '!'); if (Delim != NULL) { *Delim = '\0'; Host = Delim + 1; } GetOwner()->Log("%s (%s): %s", Dup, Delim ? Host : "<unknown host>", argv[3]); free(Dup); } free(Nick); UpdateHostHelper(Reply); return true; } else if (argc > 3 && hashRaw == hashPrivmsg && Client != NULL) { Channel = GetChannel(argv[2]); if (Channel != NULL) { Channel->AddBacklogLine(argv[0], argv[3]); } } else if (argc > 3 && hashRaw == hashNotice && Client == NULL) { const char *Dest = argv[2]; char *Nick; if (!ModuleEvent(argc, argv)) { return false; } Nick = ::NickFromHostmask(Reply); /* don't log ctcp replies */ if (argv[3][0] != '\1' && argv[3][strlen(argv[3]) - 1] != '\1' && Dest != NULL && Nick != NULL && m_CurrentNick != NULL && strcasecmp(Dest, m_CurrentNick) == 0 && strcasecmp(Nick, m_CurrentNick) != 0) { GetOwner()->Log("%s (notice): %s", Reply, argv[3]); } free(Nick); return true; } else if (argc > 2 && hashRaw == hashJoin) { if (b_Me) { AddChannel(argv[2]); /* GetOwner() can be NULL if AddChannel failed */ if (GetOwner() != NULL && Client == NULL) { WriteLine("MODE %s", argv[2]); } } Channel = GetChannel(argv[2]); if (Channel != NULL) { Nick = NickFromHostmask(Reply); if (AllocFailed(Nick)) { return false; } Channel->AddUser(Nick, '\0'); free(Nick); } UpdateHostHelper(Reply); } else if (argc > 2 && hashRaw == hashPart) { bool bRet = ModuleEvent(argc, argv); if (b_Me) { RemoveChannel(argv[2]); } else { Channel = GetChannel(argv[2]); if (Channel != NULL) { Nick = ::NickFromHostmask(Reply); if (AllocFailed(Nick)) { return false; } Channel->RemoveUser(Nick); free(Nick); } } UpdateHostHelper(Reply); return bRet; } else if (argc > 3 && hashRaw == hashKick) { bool bRet = ModuleEvent(argc, argv); if (m_CurrentNick != NULL && strcasecmp(argv[3], m_CurrentNick) == 0) { RemoveChannel(argv[2]); if (Client == NULL) { char *Dup = strdup(Reply); if (AllocFailed(Dup)) { return bRet; } char *Delim = strchr(Dup, '!'); const char *Host = NULL; if (Delim) { *Delim = '\0'; Host = Delim + 1; } GetOwner()->Log("%s (%s) kicked you from %s (%s)", Dup, Delim ? Host : "<unknown host>", argv[2], argc > 4 ? argv[4] : ""); free(Dup); } } else { Channel = GetChannel(argv[2]); if (Channel != NULL) { Channel->RemoveUser(argv[3]); } } UpdateHostHelper(Reply); return bRet; } else if (argc > 2 && iRaw == 1) { if (Client != NULL) { if (strcmp(Client->GetNick(), argv[2]) != 0) { Client->WriteLine(":%s!%s NICK :%s", Client->GetNick(), m_Site ? m_Site : "*****@*****.**", argv[2]); } } free(m_CurrentNick); m_CurrentNick = strdup(argv[2]); free(m_Server); m_Server = strdup(Reply); } else if (argc > 2 && hashRaw == hashNick) { if (b_Me) { free(m_CurrentNick); m_CurrentNick = strdup(argv[2]); } Nick = NickFromHostmask(argv[0]); int i = 0; if (!b_Me && GetOwner()->GetClientConnectionMultiplexer() == NULL) { const char *AwayNick = GetOwner()->GetAwayNick(); if (AwayNick != NULL && strcasecmp(AwayNick, Nick) == 0) { WriteLine("NICK %s", AwayNick); } } while (hash_t<CChannel *> *ChannelHash = m_Channels->Iterate(i++)) { ChannelHash->Value->RenameUser(Nick, argv[2]); } free(Nick); } else if (argc > 1 && hashRaw == hashQuit) { bool bRet = ModuleEvent(argc, argv); Nick = NickFromHostmask(argv[0]); int i = 0; while (hash_t<CChannel *> *ChannelHash = m_Channels->Iterate(i++)) { ChannelHash->Value->RemoveUser(Nick); } free(Nick); return bRet; } else if (argc > 1 && (iRaw == 422 || iRaw == 376)) { int DelayJoin = GetOwner()->GetDelayJoin(); if (m_State != State_Connected) { const CVector<CModule *> *Modules = g_Bouncer->GetModules(); for (int i = 0; i < Modules->GetLength(); i++) { (*Modules)[i]->ServerLogon(GetOwner()->GetUsername()); } const char *ClientNick; if (Client != NULL) { ClientNick = Client->GetNick(); if (strcmp(m_CurrentNick, ClientNick) != 0) { Client->ChangeNick(m_CurrentNick); } } GetOwner()->Log("You were successfully connected to an IRC server."); g_Bouncer->Log("User %s connected to an IRC server.", GetOwner()->GetUsername()); } if (DelayJoin == 1) { m_DelayJoinTimer = g_Bouncer->CreateTimer(5, false, DelayJoinTimer, this); } else if (DelayJoin == 0) { JoinChannels(); } if (Client == NULL) { bool AppendTS = (GetOwner()->GetConfig()->ReadInteger("user.ts") != 0); const char *AwayReason = GetOwner()->GetAwayText(); if (AwayReason != NULL) { WriteLine(AppendTS ? "AWAY :%s (Away since the dawn of time)" : "AWAY :%s", AwayReason); } } const char *AutoModes = GetOwner()->GetAutoModes(); const char *DropModes = GetOwner()->GetDropModes(); if (AutoModes != NULL) { WriteLine("MODE %s +%s", GetCurrentNick(), AutoModes); } if (DropModes != NULL && Client == NULL) { WriteLine("MODE %s -%s", GetCurrentNick(), DropModes); } m_State = State_Connected; } else if (argc > 1 && strcasecmp(Reply, "ERROR") == 0) { if (strstr(Raw, "throttle") != NULL) { GetOwner()->ScheduleReconnect(120); } else { GetOwner()->ScheduleReconnect(5); } if (GetCurrentNick() != NULL && GetSite() != NULL) { g_Bouncer->LogUser(GetUser(), "Error received for user %s [%s!%s]: %s", GetOwner()->GetUsername(), GetCurrentNick(), GetSite(), argv[1]); } else { g_Bouncer->LogUser(GetUser(), "Error received for user %s: %s", GetOwner()->GetUsername(), argv[1]); } } else if (argc > 3 && iRaw == 465) { if (GetCurrentNick() != NULL && GetSite() != NULL) { g_Bouncer->LogUser(GetUser(), "G/K-line reason for user %s [%s!%s]: %s", GetOwner()->GetUsername(), GetCurrentNick(), GetSite(), argv[3]); } else { g_Bouncer->LogUser(GetUser(), "G/K-line reason for user %s: %s", GetOwner()->GetUsername(), argv[3]); } } else if (argc > 5 && iRaw == 351) { free(m_ServerVersion); m_ServerVersion = strdup(argv[3]); free(m_ServerFeat); m_ServerFeat = strdup(argv[5]); } else if (argc > 3 && iRaw == 5) { for (int i = 3; i < argc - 1; i++) { char *Dup = strdup(argv[i]); if (AllocFailed(Dup)) { return false; } char *Eq = strchr(Dup, '='); if (strcasecmp(Dup, "NAMESX") == 0) { WriteLine("PROTOCTL NAMESX"); } char *Value; if (Eq) { *Eq = '\0'; Value = strdup(++Eq); } else { Value = strdup(""); } m_ISupport->Add(Dup, Value); free(Dup); } } else if (argc > 4 && iRaw == 324) { Channel = GetChannel(argv[3]); if (Channel != NULL) { Channel->ClearModes(); Channel->ParseModeChange(argv[0], argv[4], argc - 5, &argv[5]); Channel->SetModesValid(true); } } else if (argc > 3 && hashRaw == hashMode) { Channel = GetChannel(argv[2]); if (Channel != NULL) { Channel->ParseModeChange(argv[0], argv[3], argc - 4, &argv[4]); } else if (strcmp(m_CurrentNick, argv[2]) == 0) { bool Flip = true, WasNull; const char *Modes = argv[3]; size_t Length = strlen(Modes) + 1; if (m_Usermodes != NULL) { Length += strlen(m_Usermodes); } WasNull = (m_Usermodes != NULL) ? false : true; m_Usermodes = (char *)realloc(m_Usermodes, Length); if (AllocFailed(m_Usermodes)) { return false; } if (WasNull) { m_Usermodes[0] = '\0'; } while (*Modes != '\0') { if (*Modes == '+') { Flip = true; } else if (*Modes == '-') { Flip = false; } else { if (Flip) { size_t Position = strlen(m_Usermodes); m_Usermodes[Position] = *Modes; m_Usermodes[Position + 1] = '\0'; } else { char *CurrentModes = m_Usermodes; size_t a = 0; while (*CurrentModes != '\0') { *CurrentModes = m_Usermodes[a]; if (*CurrentModes != *Modes) { CurrentModes++; } a++; } } } Modes++; } } UpdateHostHelper(Reply); } else if (argc > 4 && iRaw == 329) { Channel = GetChannel(argv[3]); if (Channel != NULL) { Channel->SetCreationTime(atoi(argv[4])); } } else if (argc > 4 && iRaw == 332) { Channel = GetChannel(argv[3]); if (Channel != NULL) { Channel->SetTopic(argv[4]); } } else if (argc > 5 && iRaw == 333) { Channel = GetChannel(argv[3]); if (Channel != NULL) { Channel->SetTopicNick(argv[4]); Channel->SetTopicStamp(atoi(argv[5])); } } else if (argc > 3 && iRaw == 331) { Channel = GetChannel(argv[3]); if (Channel != NULL) { Channel->SetNoTopic(); } } else if (argc > 3 && hashRaw == hashTopic) { Channel = GetChannel(argv[2]); if (Channel != NULL) { Channel->SetTopic(argv[3]); Channel->SetTopicStamp(g_CurrentTime); Channel->SetTopicNick(argv[0]); } UpdateHostHelper(Reply); } else if (argc > 5 && iRaw == 353) { Channel = GetChannel(argv[4]); if (Channel != NULL) { const char *nicks; const char **nickv; nicks = ArgTokenize(argv[5]); if (AllocFailed(nicks)) { return false; } nickv = ArgToArray(nicks); if (AllocFailed(nickv)) { ArgFree(nicks); return false; } int nickc = ArgCount(nicks); for (int i = 0; i < nickc; i++) { char *Nick = strdup(nickv[i]); char *BaseNick = Nick; if (AllocFailed(Nick)) { ArgFree(nicks); return false; } StrTrim(Nick, ' '); while (IsNickPrefix(*Nick)) { Nick++; } char *Modes = NULL; if (BaseNick != Nick) { Modes = (char *)malloc(Nick - BaseNick + 1); if (!AllocFailed(Modes)) { strmcpy(Modes, BaseNick, Nick - BaseNick + 1); } } Channel->AddUser(Nick, Modes); free(BaseNick); free(Modes); } ArgFreeArray(nickv); ArgFree(nicks); } } else if (argc > 3 && iRaw == 366) { Channel = GetChannel(argv[3]); if (Channel != NULL) { Channel->SetHasNames(); } } else if (argc > 9 && iRaw == 352) { const char *Ident = argv[4]; const char *Host = argv[5]; const char *Server = argv[6]; const char *Nick = argv[7]; const char *Realname = argv[9]; char *Mask; int rc = asprintf(&Mask, "%s!%s@%s", Nick, Ident, Host); if (!RcFailed(rc)) { UpdateHostHelper(Mask); UpdateWhoHelper(Nick, Realname, Server); free(Mask); } } else if (argc > 6 && iRaw == 367) { Channel = GetChannel(argv[3]); if (Channel != NULL) { Channel->GetBanlist()->SetBan(argv[4], argv[5], atoi(argv[6])); } } else if (argc > 3 && iRaw == 368) { Channel = GetChannel(argv[3]); if (Channel != NULL) { Channel->SetHasBans(); } } else if (argc > 3 && iRaw == 396) { free(m_Site); m_Site = strdup(argv[3]); if (AllocFailed(m_Site)) {} } else if (argc > 3 && hashRaw == hashPong && m_Server != NULL && strcasecmp(argv[2], m_Server) == 0 && m_EatPong) { m_EatPong = false; return false; } else if (argc > 3 && iRaw == 421) { m_FloodControl->Unplug(); return false; } if (GetOwner() != NULL) { return ModuleEvent(argc, argv); } else { return true; } }
void HelpEditor::PartDeactivated(const IWorkbenchPartReference::Pointer& partRef) { if (partRef == GetSite()->GetPage()->GetReference(IWorkbenchPart::Pointer(this))) disableShortcuts(); }
void FxInternal::LoadLegacy() { MStatus stat= MStatus::kSuccess; MString filename; int cParamCount=0; MFnDependencyNode depNode(GetSite()); {//PARAMTER COUNT MPlug plugParamCount= depNode.findPlug("DXCC_FxParam_Count"); if(plugParamCount.isNull()) return; DXCHECK_MSTATUS(plugParamCount.getValue(cParamCount)); depNode.removeAttribute( plugParamCount.attribute() ); }//END//PARAMTER COUNT for(int iParam= 0; iParam < cParamCount; iParam++) { MString szName; MObject oData; MPlug plugName= depNode.findPlug(MString("DXCC_FxParam_Name")+iParam, &stat); if(plugName.isNull()) continue; DXCHECK_MSTATUS( plugName.getValue(szName) ); depNode.removeAttribute( plugName.attribute() ); CStringA newParamPlugName= TranscodeHandleToPlug( szName.asChar() ); MPlug newParamPlug= DecodePlug( newParamPlugName ); if(newParamPlug.isNull()) continue; MPlug plugData= depNode.findPlug(MString("DXCC_FxParam_Data")+iParam, &stat); if(plugData.isNull()) continue; DXCHECK_MSTATUS( plugData.getValue(oData) ); if(oData.hasFn( MFn::kStringData )) { MString dataStr; DXCHECK_MSTATUS( plugData.getValue(dataStr) ); newParamPlug.setValue( dataStr ); } else if(oData.hasFn( MFn::kDoubleArrayData )) { MFnDoubleArrayData dArrayData(oData); MDoubleArray dArray= dArrayData.array(); for(UINT iSub= 0; iSub < dArray.length(); iSub++) { MPlug subPlug= newParamPlug.elementByLogicalIndex( iSub ); if(subPlug.isNull()) continue; subPlug.setValue( dArray[iSub] ); } } depNode.removeAttribute( plugData.attribute() ); } }
void MgSiteConnection::AuthenticateWithSiteServer(MgUserInformation* userInformation) { assert(NULL != userInformation); Ptr<MgSite> site = GetSite(); // GetSite() performs authentication }
//THIS FUNCTION IS QUITE COMPLICATED BECAUSE //IT HAS TO DEAL WITH MAYA NAME MANGLING! //tokenize the path. //add each token into the element list which tracks the attributes and indices //for each entry added make sure there are no parents left out from maya name mangling. //after the list is populated and missing elements area added //we reiterate and produce the final result. MPlug FxInternal::DecodePlug(const CStringA& plugStr) { MPlug result; MFnDependencyNode depNode(GetSite()); CAtlList<PathDecodeElement> elementList; //tokenize the path int iLastPos=0; int iThisPos=0; CStringA subStr; while( iLastPos= iThisPos, subStr=plugStr.Tokenize(".[]", iThisPos), iThisPos != -1 ) { //char lastChar= subStr[iLastPos]; //char thisChar= subStr[iThisPos]; //are we looking at a named portion? if(iLastPos == 0 || plugStr[iLastPos-1]=='.' || (plugStr[iLastPos-1]==']' && plugStr[iLastPos]=='.')) { //if the name is length zero then it must be the case when // you do last[#]. The situation is caused by the sequence "]." //if we dont have a name we can skip since only 1d arrays are allowed. if(subStr.GetLength() > 0) { //everything we add is going to be based on the current tail. //because we are adding parents, as we find parents we can continue //to add them to this position so that they will order themselves properly POSITION insertPos= elementList.GetTailPosition(); //calculate the cancel condition. //it is the current tail's object if a tail exists otherwise NULL //NULL indicates go all the way to the root MObject cancelObj= MObject::kNullObj; if(elementList.GetCount() > 0) { cancelObj= elementList.GetTail().Attribute.object(); } //get the object we are currently working with MObject thisObj= depNode.attribute(subStr.GetString()); if(thisObj.isNull()) return MPlug();//Critical element of the path was not found...return NULL //add it to the list so that we have something to insertBefore elementList.AddTail(); elementList.GetTail().Name= subStr; elementList.GetTail().Attribute.setObject(thisObj); //walk through all of the parents until we reach cancel condition. //we can add the current element onto the list in the same way. for( MFnAttribute itrAttr( elementList.GetTail().Attribute.parent() ); !itrAttr.object().isNull() && (cancelObj != itrAttr.object()); itrAttr.setObject(itrAttr.parent())) { PathDecodeElement element; element.Attribute.setObject( itrAttr.object() ); //we change the position so that the grandparent is inserted before the parent insertPos= elementList.InsertBefore( insertPos, element); } } } //are we looking at a numbered portion? else if(plugStr[iLastPos-1]=='[' && plugStr[iThisPos-1]==']') { //if so change the array index. elementList.GetTail().IsArray= true; elementList.GetTail().Index = atoi( subStr.GetString() ); } else DXCC_ASSERT(false);//VERY POORLY FORMED STRING } //produce the result plug off of the elementList. bool first= true; for(POSITION pos= elementList.GetHeadPosition(); pos != NULL; elementList.GetNext(pos)) { PathDecodeElement& element= elementList.GetAt(pos); if(first) {//on first one we initialize the result first= false; result= MPlug( GetSite(), element.Attribute.object() ); } else { result= result.child( element.Attribute.object() ); } if(element.IsArray) { result= result.elementByLogicalIndex(element.Index); } if(result.isNull()) return MPlug();//Critical element of the path was not found...return NULL } return result; }
void CLobbyApp::SetPlayerMission(const char* szPlayerName, const char* szCDKey, CFLMission* pMission, const char* szAddress) { debugf("SetPlayerMission(): Setting player mission for: %s, CDKey: %s", szPlayerName, szCDKey); ZString strPlayerName = szPlayerName; ZString strCDKey = szCDKey; ZString strAddress = szAddress; // boot any old copies of this player #ifdef USECLUB BootPlayersByName(strPlayerName); #endif // BT - 7/15 - CSS Integration if (IsCssAuthenticationEnabled() == true) { // BT - 9/11/2010 - Readding CD Key Auth on player join to the Allegiance server. int resultMessageLength = 1024; char resultMessage[1024]; debugf("SetPlayerMission(): checking valid key for: %s, cdKey: %s, IP: %s\r\n", szPlayerName, szCDKey, szAddress); bool cdKeyIsValid = true; //CDKeyIsValid(szPlayerName, szCDKey, szAddress, resultMessage, resultMessageLength); debugf("SetPlayerMission(): keycheck for: %s, key: %s, address: %s, result: %s, succeeded: %s\r\n", szPlayerName, szCDKey, szAddress, resultMessage, (cdKeyIsValid == true) ? "true" : "false"); if (cdKeyIsValid == false) { BEGIN_PFM_CREATE(m_fmServers, pfmRemovePlayer, L, REMOVE_PLAYER) FM_VAR_PARM(szPlayerName, CB_ZTS) FM_VAR_PARM(resultMessage, CB_ZTS) END_PFM_CREATE pfmRemovePlayer->dwMissionCookie = pMission->GetCookie(); pfmRemovePlayer->reason = RPR_duplicateCDKey; m_fmServers.SendMessages(pMission->GetServer()->GetConnection(), FM_GUARANTEED, FM_FLUSH); GetSite()->LogEvent(EVENTLOG_WARNING_TYPE, LE_BadCDKey, szCDKey, pMission->GetServer()->GetConnection()->GetName(), szPlayerName); } else // BT - 9/11/2010 - End. { ZString strOldPlayer; if (BootPlayersByCDKey(strCDKey, szPlayerName, strOldPlayer)) { BEGIN_PFM_CREATE(m_fmServers, pfmRemovePlayer, L, REMOVE_PLAYER) FM_VAR_PARM(szPlayerName, CB_ZTS) FM_VAR_PARM((PCC)strOldPlayer, CB_ZTS) END_PFM_CREATE pfmRemovePlayer->dwMissionCookie = pMission->GetCookie(); pfmRemovePlayer->reason = RPR_duplicateCDKey; m_fmServers.SendMessages(pMission->GetServer()->GetConnection(), FM_GUARANTEED, FM_FLUSH); } } } // create a new player by creating entries in the maps PlayerByCDKey::iterator iterPlayerByCDKey = m_playerByCDKey.insert(PlayerByCDKey::value_type(strCDKey, PlayerLocInfo(strPlayerName, pMission))); m_playerByName.insert(PlayerByName::value_type(strPlayerName, iterPlayerByCDKey)); pMission->AddPlayer(); }
_DndFrameWidgetLayout->addWidget(m_NodeTreeView, 0, 0); _DndFrameWidgetLayout->setContentsMargins(0,0,0,0); m_DndFrameWidget = new QmitkDnDFrameWidget(m_Parent); m_DndFrameWidget->setLayout(_DndFrameWidgetLayout); QVBoxLayout* layout = new QVBoxLayout(parent); layout->addWidget(m_DndFrameWidget); layout->setContentsMargins(0,0,0,0); m_Parent->setLayout(layout); m_SelectionListener = new berry::SelectionChangedAdapter<QmitkDataManagerView> (this, &QmitkDataManagerView::SelectionChanged); berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); s->AddSelectionListener(m_SelectionListener); } void QmitkDataManagerView::SetFocus() { } void QmitkDataManagerView::ContextMenuActionTriggered( bool ) { QAction* action = qobject_cast<QAction*> ( sender() ); std::map<QAction*, berry::IConfigurationElement::Pointer>::iterator it = m_ConfElements.find( action ); if( it == m_ConfElements.end() )