void SelectDrawWidget::GoToWWWDocumentation(DrawInfo *d) { if (d->IsValid() == false) return; TParam *p = d->GetParam()->GetIPKParam(); TSzarpConfig* sc = p->GetSzarpConfig(); wxString link = sc->GetDocumentationBaseURL(); if (link.IsEmpty()) link = _T("http://www.szarp.com"); link += _T("/cgi-bin/param_docs.py?"); link << _T("prefix=") << d->GetBasePrefix().c_str(); link << _T("¶m=") << encode_string(p->GetName().c_str()); TUnit* u; if ((u = p->GetParentUnit())) { TDevice* dev = u->GetDevice(); link << _T("&path=") << encode_string(dev->GetPath().c_str()); } int validity = 8 * 3600; std::wstringstream tss; tss << (wxDateTime::Now().GetTicks() / validity * validity); link << _T("&id=") << sz_md5(tss.str()); #if __WXMSW__ if (wxLaunchDefaultBrowser(link) == false) #else if (wxExecute(wxString::Format(_T("xdg-open %s"), link.c_str())) == 0) #endif wxMessageBox(_("I was not able to start default browser"), _("Error"), wxICON_ERROR | wxOK, this); }
void* QueryExecutor::Entry() { DatabaseQuery *q = NULL; #if 0 try { #endif while ((q = queue->GetQuery())) { bool post_response = false; if (q->type == DatabaseQuery::STARTING_CONFIG_RELOAD) { szbase->RemoveConfig(q->reload_prefix.prefix, true); post_response = true; } else if (q->type == DatabaseQuery::COMPILE_FORMULA) { std::wstring error; bool ret; #ifndef NO_LUA ret = szbase->CompileLuaFormula(q->compile_formula.formula, error); q->compile_formula.ok = ret; if (ret == false) q->compile_formula.error = wcsdup(error.c_str()); #else q->compile_formula.ok = false; q->compile_formula.error = strdup(error.c_str()); #endif post_response = true; #ifndef NO_LUA } else if (q->type == DatabaseQuery::ADD_PARAM) { TParam *p = q->defined_param.p; wchar_t *prefix = q->defined_param.prefix; szbase->AddExtraParam(prefix, p); post_response = false; free(prefix); } else if (q->type == DatabaseQuery::REMOVE_PARAM) { TParam *p = q->defined_param.p; wchar_t *prefix = q->defined_param.prefix; szbase->RemoveExtraParam(prefix, p); post_response = true; #endif } else if (q->type == DatabaseQuery::CHECK_CONFIGURATIONS_CHANGE) { szbase->NotifyAboutConfigurationChanges(); post_response = false; } else if (q->type == DatabaseQuery::SET_PROBER_ADDRESS) { szbase->SetProberAddress(q->prefix, q->prober_address.address, q->prober_address.port); free(q->prober_address.address); free(q->prober_address.port); post_response = false; } else if (q->type == DatabaseQuery::EXTRACT_PARAM_VALUES) { ExecuteExtractParametersQuery(q->extraction_parameters); post_response = false; } else { TParam *p = NULL; TSzarpConfig *cfg = NULL; szb_buffer_t *szb = NULL; if (q->param) { p = q->param; cfg = p->GetSzarpConfig(); szb = szbase->GetBuffer(cfg->GetPrefix()); } switch (q->type) { case DatabaseQuery::SEARCH_DATA: szbase->NextQuery(); ExecuteSearchQuery(szb, p, q->search_data); post_response = true; break; case DatabaseQuery::GET_DATA: szbase->NextQuery(); ExecuteDataQuery(szb, p, q); post_response = false; break; case DatabaseQuery::RESET_BUFFER: if (szb) szb_reset_buffer(szb); break; case DatabaseQuery::CLEAR_CACHE: if (cfg) szbase->ClearCacheDir(cfg->GetPrefix().c_str()); break; default: break; } } if (post_response) { DatabaseResponse r(q); wxPostEvent(response_receiver, r); } else delete q; } #if 0 } catch (std::exception &e) { std::cout << e.what() << std::endl; } #endif Szbase::Destroy(); return NULL; }