11 #include "TGTextEntry.h"
12 #include "TPluginManager.h"
16 #include "TVirtualX.h"
24 FWHtml(
const TGWindow*
p,
int w,
int h,
int id = -1):
42 {
"http://",
"Web site known by you",0},
43 {
"file:",
"Local file [you must type full path name]",0},
44 {
"dcap://",
"dCache [FNAL]",0},
45 {
"rfio://",
"Castor [CERN]",0}
56 getURLResponseTime(
const char*
url)
58 TString com =
"ping -q -c 1 -n " + TString(url) +
"| tail -n 1";
59 FILE*
p = gSystem->OpenPipe(com,
"r");
62 gSystem->ClosePipe(p);
64 TPMERegexp re(
"([\\d\\.]+)");
73 const char* windowname,
74 const TGWindow* p, UInt_t
w, UInt_t
h)
75 : TGTransientFrame(gClient->GetDefaultRoot(), p, w, h)
77 TGVerticalFrame* vf =
new TGVerticalFrame(
this);
78 this->AddFrame(vf,
new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,5,5,5,5));
79 TGHorizontalFrame* urlFrame =
new TGHorizontalFrame(
this);
80 vf->AddFrame(urlFrame,
new TGLayoutHints(kLHintsExpandX,5,0,5,5));
82 TGLabel* urlLabel =
new TGLabel(urlFrame,
"URL");
83 urlFrame->AddFrame(urlLabel,
new TGLayoutHints(kLHintsLeft|kLHintsCenterY,1,1,1,1));
85 urlFrame->AddFrame(
m_choosePrefix,
new TGLayoutHints(kLHintsLeft,1,1,1,1));
87 m_file=
new TGTextEntry(urlFrame);
88 urlFrame->AddFrame(
m_file,
new TGLayoutHints(kLHintsExpandX,1,0,1,1));
89 m_file->Connect(
"TextChanged(const char*)",
"CmsShowSearchFiles",
this,
"fileEntryChanged(const char*)");
90 m_file->Connect(
"ReturnPressed()",
"CmsShowSearchFiles",
this,
"updateBrowser()");
93 m_webFile->Connect(
"MouseDown(const char*)",
"CmsShowSearchFiles",
this,
"hyperlinkClicked(const char*)");
94 vf->AddFrame(
m_webFile,
new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,1,1,1,1));
96 TGHorizontalFrame* buttonFrame =
new TGHorizontalFrame(vf);
97 vf->AddFrame(buttonFrame,
new TGLayoutHints(kLHintsExpandX,1,10,1,10));
100 buttonFrame->AddFrame(
m_openButton,
new TGLayoutHints(kLHintsRight,5,5,1,1));
102 m_openButton->Connect(
"Clicked()",
"CmsShowSearchFiles",
this,
"openClicked()");
104 TGTextButton* cancel =
new TGTextButton(buttonFrame,
"Cancel");
105 buttonFrame->AddFrame(cancel,
new TGLayoutHints(kLHintsRight,5,5,1,1));
106 cancel->Connect(
"Clicked()",
"CmsShowSearchFiles",
this,
"UnmapWindow()");
108 SetWindowName(windowname);
109 float x1 = getURLResponseTime(
"lxplus.cern.ch");
110 float x2 = getURLResponseTime(
"uaf-2.t2.ucsd.edu");
114 if (x1 > 0 && x1 < x2)
128 m_choosePrefix->Connect(
"Clicked()",
"CmsShowSearchFiles",
this,
"showPrefixes()");
149 gClient->ProcessEventsFor(
this);
164 size_t index = fileName.find_last_of(
".");
166 if(index != std::string::npos) {
167 postfix=fileName.substr(index,std::string::npos);
191 m_file->SetText(iLink,kTRUE);
195 size_t index = fileName.find_last_of(
".");
196 std::string postfix = fileName.substr(index,std::string::npos);
230 (gPluginMgr->FindHandler(
"TSystem",prefix.c_str()) &&
231 gPluginMgr->FindHandler(
"TSystem",prefix.c_str())->CheckPlugin() != -1)) {
237 m_prefixMenu->Connect(
"Activated(Int_t)",
"CmsShowSearchFiles",
this,
"prefixChoosen(Int_t)");
254 TString
msg =
"GET ";
255 msg += fUrl.GetProtocol();
257 msg += fUrl.GetHost();
259 msg += fUrl.GetPort();
261 msg += fUrl.GetFile();
265 if (!uri.BeginsWith(
"http://"))
267 TSocket
s(fUrl.GetHost(), fUrl.GetPort());
270 if (
s.SendRaw(msg.Data(), msg.Length()) == -1)
272 Int_t
size = 1024*1024;
273 buf = (
char *)calloc(size,
sizeof(
char));
274 if (
s.RecvRaw(buf, size) == -1) {
290 size_t index = fileName.find_first_of(
":");
291 if(index != std::string::npos) {
300 gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kWatch));
303 gVirtualX->SetCursor(
m_webFile->GetId(),gVirtualX->CreateCursor(kWatch));
305 gClient->ProcessEventsFor(
this);
306 TUrl
url(fileName.c_str());
311 m_webFile->ParseText(const_cast<char*>(buffer.c_str()));
316 gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kPointer));
317 gVirtualX->SetCursor(
m_webFile->GetId(),gVirtualX->CreateCursor(kPointer));
329 const static char *s_readError[] = {
330 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ",
331 "<HTML><HEAD><TITLE>HTTP Read Error</TITLE> ",
332 "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ",
334 "<P>Unknown error while trying to get file via http</P>",
340 for (
int i=0; s_readError[
i];
i++) {
341 m_webFile->ParseText(const_cast<char *>(s_readError[
i]));
348 const static char *s_noBrowserMessage[] = {
349 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ",
350 "<HTML><HEAD><TITLE>No Browser Available</TITLE> ",
351 "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ",
355 "<b>Welcome....</b><BR>",
357 "<b>You may look at examples:</b><BR>",
358 "If you are in Europe, open example data files at CERN : ",
" <a href=" , Form(
"http://fireworks.web.cern.ch/fireworks/%d/",
fireworks::supportedDataFormatsVersion()[0] ),
"> http://fireworks.web.cern.ch/fireworks/ </a><BR>",
359 "If you are in US, open example data files at UCSD: ",
" <a href=" , Form(
"http://uaf-2.t2.ucsd.edu/fireworks/%d/",
fireworks::supportedDataFormatsVersion()[0] ),
">http://uaf-2.t2.ucsd.edu/fireworks/ </a><BR>",
361 "<b>You also may load files with Choose Prefix </b><BR>"
367 for (
int i=0; s_noBrowserMessage[
i];
i++) {
368 m_webFile->ParseText((
char *)s_noBrowserMessage[
i]);
378 Connect(
"CloseWindow()",
"CmsShowSearchFiles",
this,
"UnmapWindow()");
381 gClient->WaitForUnmap(
this);
void prefixChoosen(Int_t)
void addToVisited(const char *iToVisit)
std::vector< bool > m_prefixComplete
static const char *const s_prefixes[][s_columns]
TGTextButton * m_choosePrefix
static const std::string s_filePrefix("file:")
void fileEntryChanged(const char *)
tuple path
else: Piece not in the list, fine.
int * supportedDataFormatsVersion()
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
FWHtml(const TGWindow *p, int w, int h, int id=-1)
TGPopupMenu * m_prefixMenu
int IsVisited(const char *iCheck) override
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
TGTextButton * m_openButton
static const std::string s_httpPrefix("http:")
std::vector< std::string > m_prefixes
static const unsigned int s_columns
std::set< std::string > m_visited
void sendToWebBrowser(std::string &iWebFile)
void hyperlinkClicked(const char *)
virtual ~CmsShowSearchFiles()
static std::string readRemote(const char *url)
tuple size
Write out results.
std::string chooseFileFromURL()
This opens the dialog window and returns once the user has choosen, returns an empty string if cancel...
CmsShowSearchFiles(const char *filename, const char *windowname, const TGWindow *p=0, UInt_t w=1, UInt_t h=1)
static const std::string s_rootPostfix(".root")