libqutim  0.3.1.0
networkproxy.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** qutIM - instant messenger
00004 **
00005 ** Copyright © 2011 Alexey Prokhin <alexey.prokhin@yandex.ru>
00006 **
00007 *****************************************************************************
00008 **
00009 ** $QUTIM_BEGIN_LICENSE$
00010 ** This program is free software: you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation, either version 3 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 ** See the GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program.  If not, see http://www.gnu.org/licenses/.
00022 ** $QUTIM_END_LICENSE$
00023 **
00024 ****************************************************************************/
00025 
00026 #ifndef NETWORKPROXY_H
00027 #define NETWORKPROXY_H
00028 
00029 #include "libqutim_global.h"
00030 #include "config.h"
00031 #include <QNetworkProxy>
00032 
00033 class QIcon;
00034 
00035 namespace qutim_sdk_0_3
00036 {
00037 class LocalizedString;
00038 class DataItem;
00039 class Protocol;
00040 class Account;
00041 class NetworkProxyManagerPrivate;
00042 
00046 class LIBQUTIM_EXPORT NetworkProxyInfo
00047 {
00048 public:
00049     NetworkProxyInfo();
00050     virtual ~NetworkProxyInfo();
00058     virtual QString name() = 0;
00062     virtual QIcon icon();
00066     virtual LocalizedString description() = 0;
00075     virtual DataItem settings(const Config &config) = 0;
00079     virtual void saveSettings(Config config, const DataItem &settings) = 0;
00083     static NetworkProxyInfo *proxy(const QString &name);
00087     static QList<NetworkProxyInfo*> allProxies();
00088 protected:
00089     virtual void virtual_hook(int id, void *data);
00090 };
00091 
00098 class LIBQUTIM_EXPORT NetworkProxyManager
00099 {
00100 public:
00104     NetworkProxyManager(Protocol *protocol);
00108     virtual ~NetworkProxyManager();
00112     Protocol *protocol();
00116     virtual QList<NetworkProxyInfo*> proxies() = 0;
00122     virtual void setProxy(Account *account, NetworkProxyInfo *proxy, const DataItem &settings) = 0;
00126     static NetworkProxyManager *get(Protocol *protocol);
00130     static QList<NetworkProxyManager*> allManagers();
00134     static DataItem settings();
00142     static DataItem settings(Account *account);
00146     static QNetworkProxy toNetworkProxy(const DataItem &settings);
00147 protected:
00148     virtual void virtual_hook(int id, void *data);
00149 private:
00150     NetworkProxyManagerPrivate *p;
00151 };
00152 
00156 class LIBQUTIM_EXPORT Socks5ProxyInfo : public NetworkProxyInfo
00157 {
00158 public:
00159     virtual QString name();
00160     virtual LocalizedString description();
00161     virtual DataItem settings(const Config &config);
00162     virtual void saveSettings(Config config, const DataItem &settings);
00166     static Socks5ProxyInfo *instance();
00167 protected:
00168     Socks5ProxyInfo();
00169 };
00170 
00174 class LIBQUTIM_EXPORT HttpProxyInfo : public NetworkProxyInfo
00175 {
00176 public:
00177     virtual QString name();
00178     virtual LocalizedString description();
00179     virtual DataItem settings(const Config &config);
00180     virtual void saveSettings(Config config, const DataItem &settings);
00184     static HttpProxyInfo *instance();
00185 protected:
00186     HttpProxyInfo();
00187 };
00188 
00189 } // namespace qutim_sdk_0_3
00190 
00191 //Q_DECLARE_METATYPE(qutim_sdk_0_3::NetworkProxyInfo)
00192 Q_DECLARE_INTERFACE(qutim_sdk_0_3::NetworkProxyManager, "org.qutim.core.NetworkProxyManager");
00193 
00194 #endif // NETWORKPROXY_H
00195