GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4HttpProxy.h
Go to the documentation of this file.
1 // $Id: TGo4HttpProxy.h 1692 2015-07-09 15:56:55Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #ifndef TGO4HTTPPROXY_H
15 #define TGO4HTTPPROXY_H
16 
17 #include "TGo4ServerProxy.h"
18 
19 #include "TXMLEngine.h"
20 
21 #include <QNetworkAccessManager>
22 #include <QNetworkReply>
23 
24 class TGo4HttpProxy;
25 class TGo4HttpAccess;
26 class TGo4ObjectManager;
27 
29 class QHttpProxy : public QObject {
30  Q_OBJECT
31 
32  friend class TGo4HttpProxy;
33  friend class TGo4HttpAccess;
34 
35  protected:
36  QNetworkAccessManager qnam;
37  QNetworkReply *fHReply;
39 
40  public slots:
41  void httpFinished();
42  void httpHReqError(QNetworkReply::NetworkError);
43  void authenticationRequiredSlot(QNetworkReply*, QAuthenticator*);
44 
45  void updateRatemeter();
46  void updateHierarchy();
47 
49 
50  public:
51 
53  virtual ~QHttpProxy();
54 
55  void StartRequest(const char* url);
56 };
57 
58 // -----------------------------------------------------------------------------------
59 
60 class TGo4HttpAccess : public QObject, public TGo4Access {
61 
62  Q_OBJECT
63 
64  protected:
66  XMLNodePointer_t fNode;
67  TString fUrlPath;
68  // Request kind. Can be:
69  // 0 - h.xml request,
70  // 1 - root.bin request,
71  // 2 - dabc get.xml request,
72  // 3 - dabc get.xml history requests
73  // 4 - parameter status request
74  // 5 - sample tree
75  // 6 - analysis status request
76  Int_t fKind;
77  TString fNameAttr;
78  TString fKindAttr;
79  TString fExtraArg;
81  TString fRecvPath;
82  QNetworkReply *fReply;
83 
84  public slots:
85  void httpFinished();
86  void httpError(QNetworkReply::NetworkError);
87 
88  public:
89 
90  TGo4HttpAccess(TGo4HttpProxy* proxy, XMLNodePointer_t node, Int_t kind = 1, const char* extra_arg = 0);
91 
92  virtual ~TGo4HttpAccess() { }
93 
94  virtual Bool_t IsRemote() const { return kTRUE; }
95 
96  virtual Bool_t CanGetObject() const { return kFALSE; }
97 
98  virtual Bool_t GetObject(TObject* &obj, Bool_t &owner) const { return kFALSE; }
99 
100  virtual TClass* GetObjectClass() const;
101 
102  virtual const char* GetObjectName() const;
103 
104  virtual const char* GetObjectClassName() const;
105 
106  virtual Int_t AssignObjectTo(TGo4ObjectManager* rcv, const char* path);
107 
108 };
109 
110 // -----------------------------------------------------------------------------------
111 
114 
115  friend class QHttpProxy;
116  friend class TGo4HttpAccess;
117 
118  protected:
119  TXMLEngine *fXML;
120  XMLDocPointer_t fxHierarchy;
122  Int_t fRateCnt;
123  Int_t fStatusCnt;
124  Int_t fDebugCnt;
126  TString fUserName;
127  TString fPassword;
128  Bool_t fConnected;
129  QNetworkReply *fRegularReq;
130  Int_t fShutdownCnt;
131 
132  void GetHReply(QByteArray& res);
133 
134  XMLNodePointer_t FindItem(const char* name, XMLNodePointer_t curr = 0) const;
135 
136  TString MakeUrlPath(XMLNodePointer_t item);
137 
138  void ProcessUpdateTimer();
139 
140  void ProcessRegularMultiRequest(Bool_t finished = kFALSE);
141 
142  Bool_t ServerHasRestrict();
143 
144  Bool_t ServerHasMulti();
145 
146  Bool_t SubmitURL(const char* path, Int_t waitres = -1);
147 
148  Bool_t PostObject(const char* prefix, TObject* obj, Int_t waitres = -1, Bool_t destroy_after = kTRUE);
149 
150  Bool_t CheckUserName(const char* expects, Bool_t dflt = kFALSE);
151 
152  Bool_t CheckShutdown(Bool_t force = kFALSE);
153 
154  TGo4HttpAccess* SubmitRequest(const char* itemname, Int_t kind, TGo4Slot* tgtslot, const char* extra_arg = 0);
155 
156  public:
157  TGo4HttpProxy();
158  virtual ~TGo4HttpProxy();
159 
160  void SetAccount(const char* username, const char* passwd);
161 
162  Bool_t Connect(const char* nodename);
163  Bool_t UpdateHierarchy(Bool_t sync = kTRUE);
164 
165  virtual void Initialize(TGo4Slot* slot);
166  virtual void Finalize(TGo4Slot* slot) {}
167 
168  virtual Bool_t HasSublevels() const;
169  virtual TGo4Access* ProvideAccess(const char* name);
170  virtual TGo4LevelIter* MakeIter();
171 
172  virtual Int_t GetObjectKind() { return TGo4Access::kndFolder; }
173  virtual const char* GetContainedClassName() { return ClassName(); }
174  virtual TObject* GetAssignedObject() { return this; }
175  virtual const char* GetContainedObjectInfo();
176  virtual Int_t GetObjectSizeInfo() { return -1; }
177 
178  virtual void WriteData(TGo4Slot* slot, TDirectory* dir, Bool_t onlyobjs);
179  virtual void ReadData(TGo4Slot* slot, TDirectory* dir);
180 
181  virtual void Update(TGo4Slot* slot, Bool_t strong);
182 
183  virtual TString FindCommand(const char* name);
184  virtual Int_t NumCommandArgs(const char* name);
185  virtual Bool_t SubmitCommand(const char* name, Int_t waitres = -1, const char* arg1 = 0, const char* arg2 = 0, const char* arg3 = 0);
186 
187  virtual const char* GetUserName() const { return fUserName.Data(); }
188 
189  virtual Bool_t IsAnalysisServer() const { return kTRUE; }
190  virtual Bool_t IsGo4Analysis() const;
191  virtual Bool_t IsConnected() { return fConnected; }
192  virtual Bool_t IsViewer() { return CheckUserName("observer", kFALSE); }
193  virtual Bool_t IsController() { return CheckUserName("controller", kFALSE); }
194  virtual Bool_t IsAdministrator() { return CheckUserName("admin", kTRUE); }
195 
196  virtual Bool_t CanSubmitObjects();
197  virtual void RequestAnalysisSettings();
198  virtual void SubmitAnalysisSettings();
199  virtual void CloseAnalysisSettings();
200 
201  virtual Bool_t NamesListReceived();
202  virtual Bool_t RefreshNamesList();
203  virtual Bool_t DelayedRefreshNamesList(Int_t delay_sec);
204 
205  virtual Bool_t IsAnalysisRunning() const { return fbAnalysisRunning; }
206  virtual void StartAnalysis();
207  virtual void StopAnalysis();
208 
209  virtual Bool_t RequestObjectStatus(const char* objectname, TGo4Slot* tgtslot);
210 
211  virtual Bool_t UpdateAnalysisObject(const char* objectname, TObject* obj);
212 
213  virtual void ClearAllAnalysisObjects();
214  virtual void ClearAnalysisObject(const char* fullpath);
215 
216  virtual void RemoteTreeDraw(const char* treename,
217  const char* varexp,
218  const char* cutcond,
219  const char* hname);
220 
221  virtual void RequestEventStatus(const char* evname, Bool_t astree, TGo4Slot* tgtslot);
222 
223  virtual void RemotePrintEvent(const char* evname,
224  Int_t evnumber,
225  Int_t subid,
226  Bool_t ishex,
227  Bool_t islong);
228 
229  virtual void ChageObjectProtection(const char* fullpath, const char* flags);
230 
231  virtual void RemoveObjectFromAnalysis(const char* fullpath);
232 
233  virtual void ExecuteLine(const char* line);
234 
235  virtual void PrintDynListEntry(const char* fullpath);
236 
237  virtual void LoadConfigFile(const char* fname);
238  virtual void SaveConfigFile(const char* fname);
239 
240  virtual void WriteAutoSave(const char* fname,
241  Int_t complevel,
242  Bool_t overwrite);
243 
244  virtual void ResetDebugOutputRequests();
245 
246  virtual void DisconnectAnalysis(Int_t waittime = 30, Bool_t servershutdown = kFALSE);
247 
248 
249 };
250 
251 #endif
TGo4HttpProxy * fProxy
used only to receive hierarchy
Definition: TGo4HttpProxy.h:38
virtual Int_t AssignObjectTo(TGo4ObjectManager *rcv, const char *path)
TString fPassword
user name and password -
virtual void RequestAnalysisSettings()
virtual void CloseAnalysisSettings()
Int_t fStatusCnt
counter for ratemeter updates
virtual void DisconnectAnalysis(Int_t waittime=30, Bool_t servershutdown=kFALSE)
virtual void ChageObjectProtection(const char *fullpath, const char *flags)
QNetworkReply * fReply
Definition: TGo4HttpProxy.h:82
virtual Bool_t CanSubmitObjects()
Bool_t fbAnalysisRunning
counter for debug output updates
QNetworkAccessManager qnam
Definition: TGo4HttpProxy.h:36
virtual TString FindCommand(const char *name)
virtual void ReadData(TGo4Slot *slot, TDirectory *dir)
virtual Bool_t HasSublevels() const
Int_t fDebugCnt
counter for status messages updates
virtual void Initialize(TGo4Slot *slot)
Bool_t PostObject(const char *prefix, TObject *obj, Int_t waitres=-1, Bool_t destroy_after=kTRUE)
Bool_t CheckUserName(const char *expects, Bool_t dflt=kFALSE)
virtual void ClearAnalysisObject(const char *fullpath)
Bool_t ServerHasMulti()
virtual void RequestEventStatus(const char *evname, Bool_t astree, TGo4Slot *tgtslot)
virtual Bool_t IsAnalysisServer() const
virtual Bool_t CanGetObject() const
Definition: TGo4HttpProxy.h:96
TXMLEngine * fXML
virtual Bool_t IsViewer()
virtual TClass * GetObjectClass() const
TString fRecvPath
Definition: TGo4HttpProxy.h:81
TString fNameAttr
Definition: TGo4HttpProxy.h:77
void ProcessUpdateTimer()
virtual void SaveConfigFile(const char *fname)
Bool_t SubmitURL(const char *path, Int_t waitres=-1)
virtual Bool_t IsConnected()
virtual const char * GetObjectClassName() const
void authenticationRequiredSlot(QNetworkReply *, QAuthenticator *)
virtual ~QHttpProxy()
virtual const char * GetUserName() const
QHttpProxy(TGo4HttpProxy *p)
QNetworkReply * fRegularReq
true if connected
void updateRatemeter()
Bool_t Connect(const char *nodename)
void httpFinished()
virtual TObject * GetAssignedObject()
virtual Bool_t IsAdministrator()
virtual void RemoteTreeDraw(const char *treename, const char *varexp, const char *cutcond, const char *hname)
virtual Bool_t IsRemote() const
Definition: TGo4HttpProxy.h:94
void ProcessRegularMultiRequest(Bool_t finished=kFALSE)
void StartRequest(const char *url)
virtual void ClearAllAnalysisObjects()
virtual void Update(TGo4Slot *slot, Bool_t strong)
virtual void StartAnalysis()
void GetHReply(QByteArray &res)
counter during shutdown
void SetAccount(const char *username, const char *passwd)
TGo4HttpProxy * fProxy
Definition: TGo4HttpProxy.h:65
TString fExtraArg
Definition: TGo4HttpProxy.h:79
virtual const char * GetContainedObjectInfo()
virtual Int_t NumCommandArgs(const char *name)
TGo4ObjectManager * fReceiver
Definition: TGo4HttpProxy.h:80
TGo4HttpAccess * SubmitRequest(const char *itemname, Int_t kind, TGo4Slot *tgtslot, const char *extra_arg=0)
virtual ~TGo4HttpAccess()
Definition: TGo4HttpProxy.h:92
virtual void WriteData(TGo4Slot *slot, TDirectory *dir, Bool_t onlyobjs)
QHttpProxy fComm
pointer on dabc::Hierarchy class
virtual Bool_t RequestObjectStatus(const char *objectname, TGo4Slot *tgtslot)
void httpError(QNetworkReply::NetworkError)
virtual Bool_t SubmitCommand(const char *name, Int_t waitres=-1, const char *arg1=0, const char *arg2=0, const char *arg3=0)
virtual Bool_t IsGo4Analysis() const
XMLDocPointer_t fxHierarchy
virtual Int_t GetObjectKind()
virtual void ResetDebugOutputRequests()
virtual Bool_t NamesListReceived()
virtual void LoadConfigFile(const char *fname)
virtual void RemoveObjectFromAnalysis(const char *fullpath)
void httpHReqError(QNetworkReply::NetworkError)
virtual void SubmitAnalysisSettings()
Bool_t ServerHasRestrict()
void regularRequestFinished()
virtual Bool_t RefreshNamesList()
TString fKindAttr
Definition: TGo4HttpProxy.h:78
virtual void ExecuteLine(const char *line)
QNetworkReply * fHReply
central manager of network requests
Definition: TGo4HttpProxy.h:37
virtual ~TGo4HttpProxy()
virtual const char * GetContainedClassName()
TString fUserName
virtual Bool_t UpdateAnalysisObject(const char *objectname, TObject *obj)
virtual void WriteAutoSave(const char *fname, Int_t complevel, Bool_t overwrite)
virtual TGo4LevelIter * MakeIter()
XMLNodePointer_t fNode
Definition: TGo4HttpProxy.h:66
void updateHierarchy()
TString MakeUrlPath(XMLNodePointer_t item)
virtual Int_t GetObjectSizeInfo()
virtual void Finalize(TGo4Slot *slot)
Bool_t UpdateHierarchy(Bool_t sync=kTRUE)
virtual void RemotePrintEvent(const char *evname, Int_t evnumber, Int_t subid, Bool_t ishex, Bool_t islong)
virtual const char * GetObjectName() const
TGo4HttpAccess(TGo4HttpProxy *proxy, XMLNodePointer_t node, Int_t kind=1, const char *extra_arg=0)
Bool_t CheckShutdown(Bool_t force=kFALSE)
virtual TGo4Access * ProvideAccess(const char *name)
virtual void StopAnalysis()
virtual Bool_t GetObject(TObject *&obj, Bool_t &owner) const
Definition: TGo4HttpProxy.h:98
virtual Bool_t DelayedRefreshNamesList(Int_t delay_sec)
virtual Bool_t IsAnalysisRunning() const
virtual void PrintDynListEntry(const char *fullpath)
virtual Bool_t IsController()
Int_t fShutdownCnt
multiple request for rate, log and messages
XMLNodePointer_t FindItem(const char *name, XMLNodePointer_t curr=0) const
TString fUrlPath
Definition: TGo4HttpProxy.h:67