PACK Qt Binding  $VERSION$
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
interface.h
Go to the documentation of this file.
1 // Copyright (C) 2009-2011 by Konrad Rosenbaum <konrad@silmor.de>
2 // protected under the GNU LGPL version 3 or at your option any newer.
3 // See COPYING.LGPL file that comes with this distribution.
4 //
5 
6 
7 #ifndef WOB_INTERFACE_H
8 #define WOB_INTERFACE_H
9 
10 #include <QMap>
11 #include <QObject>
12 #include <QUrl>
13 #include <QSslError>
14 
15 #include <WOb>
16 
18 class QNetworkRequest;
19 class QNetworkReply;
20 class WServerRequest;
21 class WServerReply;
22 
23 #ifndef WOLF_BASE_EXPORT
24 #define WOLF_BASE_EXPORT Q_DECL_IMPORT
25 #endif
26 
28 class WOLF_BASE_EXPORT WInterface:public QObject
29 {
30  Q_OBJECT
31  Q_PROPERTY(QUrl url READ url)
32  Q_PROPERTY(bool useProxy READ useProxy)
33  Q_PROPERTY(bool useProxyAuth READ useProxyAuth)
34  Q_PROPERTY(QString proxyHost READ proxyHost)
35  Q_PROPERTY(unsigned short proxyPort READ proxyPort)
36  Q_PROPERTY(QString proxyUser READ proxyUser)
37  Q_PROPERTY(QString proxyPassword READ proxyPassword)
38  Q_PROPERTY(int webTimeout READ webTimeout)
39  Q_PROPERTY(QString name READ name)
40  Q_ENUMS(LogLevel)
41  Q_PROPERTY(LogLevel logLevel READ logLevel)
42  protected:
44  WInterface(QString name);
45 
46  friend class WTransaction;
47  friend class WTransaction_Private;
49  QNetworkReply* post(const QNetworkRequest&request,const QByteArray&data);
50 
51  friend class WServer;
53  virtual WServerReply execute(const WServerRequest&);
54 
55  public:
56  virtual ~WInterface();
58  virtual QMap<QString,QString> headers(QString)const;
59 
61  QUrl url()const{return m_url;}
62 
64  bool useProxy()const{return m_proxyhost!="";}
66  bool useProxyAuth()const{return m_proxyuser!="";}
68  QString proxyHost()const{return m_proxyhost;}
70  unsigned short proxyPort()const{return m_proxyport;}
72  QString proxyUser()const{return m_proxyuser;}
74  QString proxyPassword()const{return m_proxypass;}
75 
77  int webTimeout()const{return m_wtimeout;}
78 
80  QString name()const;
81 
83  static WInterface*instance(QString);
84 
86  enum LogLevel {
88  LogNone=0,
90  LogMinimal=1,
92  LogInfo=2,
94  LogOnError=0x12,
96  LogDetailed=0xff
97  };
98 
100  LogLevel logLevel()const{return loglvl;}
101 
103  QString libraryVersionInfo(WOb::VersionInfo)const;
105  static QString staticLibraryVersionInfo(WOb::VersionInfo);
107  virtual QString wocVersionInfo(WOb::VersionInfo)const=0;
109  virtual QString versionInfo(WOb::VersionInfo)const=0;
110 
112  virtual QString commVersion()const{return versionInfo(WOb::VersionComm);}
114  virtual QString needCommVersion()const{return versionInfo(WOb::VersionNeedComm);}
116  virtual QString version()const{return versionInfo(WOb::VersionHR);}
117 
118  public slots:
121 
123  void setWebTimeout(int t){if(t>0)m_wtimeout=t;}
124 
126  void resetProxy(){m_proxyhost="";m_proxyport=0;m_proxyuser="";m_proxypass="";}
128  void setProxy(QString proxyhost,unsigned short proxyport,QString proxyuser=QString(),QString proxypassword=QString());
129 
131  void setUrl(QUrl u){m_url=u;}
132 
134  virtual void sslErrors(QNetworkReply *,const QList<QSslError>&);
135 
136  private:
137  static QMap<QString,WInterface*>inst;
138  QUrl m_url;
139  QString m_proxyhost,m_proxyuser,m_proxypass;
140  unsigned short m_proxyport;
141  int m_wtimeout;
142  LogLevel loglvl;
143  WobNetworkAccessManager*m_netman;
144 };
145 
146 #endif
LogLevel logLevel() const
Definition: interface.h:100
virtual QString needCommVersion() const
convenience function: return the oldest protocol version this interface is compatible with ...
Definition: interface.h:114
the oldest version of the protocol that the interface is compatible with
Definition: wob.h:18
void setLogLevel(WInterface::LogLevel l)
Definition: interface.h:120
alias for VersionHumanReadable,
Definition: wob.h:22
Definition: server.h:103
LogLevel
Definition: interface.h:86
QString proxyPassword() const
Definition: interface.h:74
virtual QString version() const
convenience function: return human readable version
Definition: interface.h:116
QUrl url() const
Definition: interface.h:61
void setWebTimeout(int t)
Definition: interface.h:123
int webTimeout() const
Definition: interface.h:77
#define WOLF_BASE_EXPORT
Definition: interface.h:24
reply object for the server side: contains the data sent back to the client
Definition: server.h:70
Definition: transaction.h:20
QString proxyUser() const
Definition: interface.h:72
Definition: transaction_p.h:50
Encapsulates the request as it comes in via (S)CGI.
Definition: server.h:23
unsigned short proxyPort() const
Definition: interface.h:70
virtual QString commVersion() const
convenience function: return the protocol version of this interface
Definition: interface.h:112
void setUrl(QUrl u)
Definition: interface.h:131
the version of the protocol that the interface implements
Definition: wob.h:16
base class of all interfaces
Definition: interface.h:28
bool useProxyAuth() const
Definition: interface.h:66
VersionInfo
version information, used in conjunction with versionInfo()
Definition: wob.h:14
Definition: wobnam.h:23
QString proxyHost() const
Definition: interface.h:68
void resetProxy()
Definition: interface.h:126
bool useProxy() const
Definition: interface.h:64