10 #include "TGTextEntry.h"
11 #include "TPluginManager.h"
14 #include "TVirtualX.h"
20 FWHtml(
const TGWindow*
p,
int w,
int h,
int id = -1):
24 std::string
check(GetBaseUri());
38 {
"http://fireworks.web.cern.ch/fireworks/",
"Pre-selected example files at CERN",
"t"},
39 {
"http://uaf-2.t2.ucsd.edu/fireworks/",
"Pre-selected example files in USA",
"t"},
40 {
"http://",
"Web site known by you",0},
41 {
"file:",
"Local file [you must type full path name]",0},
42 {
"dcap://",
"dCache [FNAL]",0},
43 {
"rfio://",
"Castor [CERN]",0}
53 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ",
54 "<HTML><HEAD><TITLE>No Browser Available</TITLE> ",
55 "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ",
59 "<b>Welcome....</b><BR>",
61 "<b>You may look at examples:</b><BR>",
62 "If you are in Europe, open example data files at CERN: <a href=http://fireworks.web.cern.ch/fireworks/>http://fireworks.web.cern.ch/fireworks/</a><BR>",
63 "If you are in US, open example data files at UCSD: <a href=http://uaf-2.t2.ucsd.edu/fireworks/>http://uaf-2.t2.ucsd.edu/fireworks/</a><BR>",
65 "<b>You also may load files with Choose Prefix </b><BR>"
71 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ",
72 "<HTML><HEAD><TITLE>HTTP Read Error</TITLE> ",
73 "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ",
75 "<P>Unknown error while trying to get file via http</P>",
82 const char* windowname,
84 : TGTransientFrame(gClient->GetDefaultRoot(), p, w, h)
86 TGVerticalFrame* vf =
new TGVerticalFrame(
this);
87 this->AddFrame(vf,
new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,5,5,5,5));
88 TGHorizontalFrame* urlFrame =
new TGHorizontalFrame(
this);
89 vf->AddFrame(urlFrame,
new TGLayoutHints(kLHintsExpandX,5,0,5,5));
91 TGLabel* urlLabel =
new TGLabel(urlFrame,
"URL");
92 urlFrame->AddFrame(urlLabel,
new TGLayoutHints(kLHintsLeft|kLHintsCenterY,1,1,1,1));
94 urlFrame->AddFrame(
m_choosePrefix,
new TGLayoutHints(kLHintsLeft,1,1,1,1));
96 m_file=
new TGTextEntry(urlFrame);
97 urlFrame->AddFrame(
m_file,
new TGLayoutHints(kLHintsExpandX,1,0,1,1));
98 m_file->Connect(
"TextChanged(const char*)",
"CmsShowSearchFiles",
this,
"fileEntryChanged(const char*)");
99 m_file->Connect(
"ReturnPressed()",
"CmsShowSearchFiles",
this,
"updateBrowser()");
102 m_webFile->Connect(
"MouseDown(const char*)",
"CmsShowSearchFiles",
this,
"hyperlinkClicked(const char*)");
103 vf->AddFrame(
m_webFile,
new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,1,1,1,1));
105 TGHorizontalFrame* buttonFrame =
new TGHorizontalFrame(vf);
106 vf->AddFrame(buttonFrame,
new TGLayoutHints(kLHintsExpandX,1,10,1,10));
109 buttonFrame->AddFrame(
m_openButton,
new TGLayoutHints(kLHintsRight,5,5,1,1));
111 m_openButton->Connect(
"Clicked()",
"CmsShowSearchFiles",
this,
"openClicked()");
113 TGTextButton* cancel =
new TGTextButton(buttonFrame,
"Cancel");
114 buttonFrame->AddFrame(cancel,
new TGLayoutHints(kLHintsRight,5,5,1,1));
115 cancel->Connect(
"Clicked()",
"CmsShowSearchFiles",
this,
"UnmapWindow()");
117 SetWindowName(windowname);
122 m_choosePrefix->Connect(
"Clicked()",
"CmsShowSearchFiles",
this,
"showPrefixes()");
140 gClient->ProcessEventsFor(
this);
151 size_t index = fileName.find_last_of(
".");
153 if(index != std::string::npos) {
154 postfix=fileName.substr(index,std::string::npos);
173 m_file->SetText(iLink,kTRUE);
177 size_t index = fileName.find_last_of(
".");
178 std::string postfix = fileName.substr(index,std::string::npos);
206 std::string
prefix = std::string((*it)[0]).substr(0,std::string((*it)[0]).find_first_of(
":")+1);
209 (gPluginMgr->FindHandler(
"TSystem",prefix.c_str()) &&
210 gPluginMgr->FindHandler(
"TSystem",prefix.c_str())->CheckPlugin() != -1)) {
211 m_prefixMenu->AddEntry((std::string((*it)[0])+
" ("+((*it)[1])+
")").c_str(),index);
216 m_prefixMenu->Connect(
"Activated(Int_t)",
"CmsShowSearchFiles",
this,
"prefixChoosen(Int_t)");
229 TString
msg =
"GET ";
230 msg += fUrl.GetProtocol();
232 msg += fUrl.GetHost();
234 msg += fUrl.GetPort();
236 msg += fUrl.GetFile();
240 if (!uri.BeginsWith(
"http://"))
241 return std::string();
242 TSocket
s(fUrl.GetHost(), fUrl.GetPort());
244 return std::string();
245 if (
s.SendRaw(msg.Data(), msg.Length()) == -1)
246 return std::string();
247 Int_t
size = 1024*1024;
248 buf = (
char *)calloc(size,
sizeof(
char));
249 if (
s.RecvRaw(buf, size) == -1) {
251 return std::string();
253 std::string returnValue(buf);
262 const std::string
fileName(iWebFile);
263 size_t index = fileName.find_first_of(
":");
264 if(index != std::string::npos) {
269 std::string
prefix = fileName.substr(0,index);
273 gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kWatch));
276 gVirtualX->SetCursor(
m_webFile->GetId(),gVirtualX->CreateCursor(kWatch));
278 gClient->ProcessEventsFor(
this);
280 std::string buffer =
readRemote(url.GetUrl());
283 m_webFile->ParseText(const_cast<char*>(buffer.c_str()));
291 gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kPointer));
292 gVirtualX->SetCursor(
m_webFile->GetId(),gVirtualX->CreateCursor(kPointer));
306 Connect(
"CloseWindow()",
"CmsShowSearchFiles",
this,
"UnmapWindow()");
309 gClient->WaitForUnmap(
this);
312 return std::string();
void prefixChoosen(Int_t)
static const char * s_readError[]
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 *)
int IsVisited(const char *iCheck)
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
FWHtml(const TGWindow *p, int w, int h, int id=-1)
TGPopupMenu * m_prefixMenu
TGTextButton * m_openButton
static const std::string s_httpPrefix("http:")
std::vector< std::string > m_prefixes
static const unsigned int s_columns
static const char * s_noBrowserMessage[]
std::set< std::string > m_visited
void hyperlinkClicked(const char *)
virtual ~CmsShowSearchFiles()
static std::string readRemote(const char *url)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
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")
void sendToWebBrowser(const char *iWebFile)