Mercurial > hg > easaier-soundaccess
diff data/fileio/HttpClient.h @ 8:d32c0a79ba39
add connection setting information reading and saving
author | lbajardsilogic |
---|---|
date | Fri, 11 May 2007 15:39:08 +0000 |
parents | |
children | ca3a5912fd78 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/fileio/HttpClient.h Fri May 11 15:39:08 2007 +0000 @@ -0,0 +1,88 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* Sound Access + EASAIER client application. + Silogic 2007. Laure Bajard. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef _HTTP_CLIENT_H_ +#define _HTTP_CLIENT_H_ + +#include <QHttp> +#include <QFile> +#include <QXmlDefaultHandler> + +#include "widgets/ConnectionSettings.h" +#include "base/XmlExportable.h" + +class ConnectionSettings; + +class HttpClient : public QHttp, public XmlExportable +{ + Q_OBJECT + +public: + HttpClient(const QString& configFileName); + virtual ~HttpClient(); + + inline bool useProxy() const {return m_useProxy;} + inline QString getProxy() const {return m_proxy;} + inline int getProxyPort() const {return m_proxyPort;} + inline QString getUserProxyId() const {return m_userProxyId;} + inline QString getPwdProxyId() const {return m_pwdProxyId;} + + inline QString getHost() const {return m_host;} + inline quint16 getHostPort() const {return m_hostPort;} + + inline void setUseProxy(const bool& ok) { m_useProxy = ok;} + inline void setProxyInfo(const QString& proxy) { m_proxy = proxy;} + inline void setProxyPortInfo(const int& port) { m_proxyPort = port;} + inline void setUserProxyId(const QString& user) { m_userProxyId = user;} + inline void setPwdProxyId(const QString& pwd) { m_pwdProxyId = pwd;} + + inline void setHostInfo(const QString& host) { m_host = host;} + inline void setHostPortInfo(const quint16 port) { m_hostPort = port;} + + void valuesChanged(ConnectionSettings* dialogBox); + + virtual QString toXmlString(QString indent = "", QString extraAttributes = "") const; + bool fromXmlString(QIODevice *file); + +private: + + bool m_useProxy; + QString m_proxy; + int m_proxyPort; + QString m_userProxyId; + QString m_pwdProxyId; + + QString m_host; + quint16 m_hostPort; +}; + + +class HttpClientConfigXmlHandler : public QXmlDefaultHandler +{ +public: + HttpClientConfigXmlHandler(HttpClient *httpClient); + + bool startElement(const QString &namespaceURI, const QString &localName, + const QString &qName, const QXmlAttributes &attributes); + bool endElement(const QString &namespaceURI, const QString &localName, + const QString &qName); + bool characters(const QString &str); + bool error(const QXmlParseException &exception); + bool fatalError(const QXmlParseException &exception); + +private: + + HttpClient *m_httpClient; + +}; +#endif \ No newline at end of file