view data/fileio/HttpClient.h @ 104:40effd83ebcf

servlet name in the file xml \ user name and pwd are encoding
author benoitrigolleau
date Thu, 12 Jul 2007 15:06:41 +0000
parents ca3a5912fd78
children
line wrap: on
line source
/* -*- 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 <QByteArray>

#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 QString getServletName() const {return m_servletName;}

	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;}
	inline void setServletNameInfo(const QString& servletName) { m_servletName = servletName;}

	void valuesChanged(ConnectionSettings* dialogBox);

	virtual QString toXmlString(QString indent = "", QString extraAttributes = "") const;
	bool fromXmlString(QIODevice *file);
	static QString encodeString(const QString& str);
	static QString decodeString(const QString& str) ;
private:

	bool		m_useProxy;
	QString		m_proxy;
	int			m_proxyPort;
	QString		m_userProxyId;
	QString		m_pwdProxyId;

	QString		m_host;
	quint16		m_hostPort;

	QString		m_servletName;


};


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