| 1 | /*
|
|---|
| 2 | * proxy.h - classes for handling proxy profiles
|
|---|
| 3 | * Copyright (C) 2003 Justin Karneges
|
|---|
| 4 | *
|
|---|
| 5 | * This program is free software; you can redistribute it and/or
|
|---|
| 6 | * modify it under the terms of the GNU General Public License
|
|---|
| 7 | * as published by the Free Software Foundation; either version 2
|
|---|
| 8 | * of the License, or (at your option) any later version.
|
|---|
| 9 | *
|
|---|
| 10 | * This program is distributed in the hope that it will be useful,
|
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | * GNU General Public License for more details.
|
|---|
| 14 | *
|
|---|
| 15 | * You should have received a copy of the GNU General Public License
|
|---|
| 16 | * along with this library; if not, write to the Free Software
|
|---|
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 18 | *
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | #ifndef PROXYDLG_H
|
|---|
| 22 | #define PROXYDLG_H
|
|---|
| 23 |
|
|---|
| 24 | #include<qvaluelist.h>
|
|---|
| 25 | #include<qgroupbox.h>
|
|---|
| 26 | #include<qdom.h>
|
|---|
| 27 | #include"ui_proxy.h"
|
|---|
| 28 |
|
|---|
| 29 | class HostPortEdit : public QWidget
|
|---|
| 30 | {
|
|---|
| 31 | Q_OBJECT
|
|---|
| 32 | public:
|
|---|
| 33 | HostPortEdit(QWidget *parent=0, const char *name=0);
|
|---|
| 34 | ~HostPortEdit();
|
|---|
| 35 |
|
|---|
| 36 | QString host() const;
|
|---|
| 37 | int port() const;
|
|---|
| 38 | void setHost(const QString &);
|
|---|
| 39 | void setPort(int);
|
|---|
| 40 | void fixTabbing(QWidget *a, QWidget *b);
|
|---|
| 41 |
|
|---|
| 42 | private:
|
|---|
| 43 | class Private;
|
|---|
| 44 | Private *d;
|
|---|
| 45 | };
|
|---|
| 46 |
|
|---|
| 47 | class ProxyItem;
|
|---|
| 48 | class ProxyManager;
|
|---|
| 49 | typedef QValueList<ProxyItem> ProxyItemList;
|
|---|
| 50 |
|
|---|
| 51 | class ProxySettings
|
|---|
| 52 | {
|
|---|
| 53 | public:
|
|---|
| 54 | ProxySettings();
|
|---|
| 55 |
|
|---|
| 56 | QString host, user, pass;
|
|---|
| 57 | int port;
|
|---|
| 58 | bool useAuth;
|
|---|
| 59 | QString url;
|
|---|
| 60 |
|
|---|
| 61 | QDomElement toXml(QDomDocument *) const;
|
|---|
| 62 | bool fromXml(const QDomElement &);
|
|---|
| 63 | };
|
|---|
| 64 |
|
|---|
| 65 | class ProxyEdit : public QGroupBox
|
|---|
| 66 | {
|
|---|
| 67 | Q_OBJECT
|
|---|
| 68 | public:
|
|---|
| 69 | ProxyEdit(QWidget *parent=0, const char *name=0);
|
|---|
| 70 | ~ProxyEdit();
|
|---|
| 71 |
|
|---|
| 72 | void reset();
|
|---|
| 73 | void setType(const QString &s);
|
|---|
| 74 | ProxySettings proxySettings() const;
|
|---|
| 75 | void setProxySettings(const ProxySettings &);
|
|---|
| 76 | void fixTabbing(QWidget *a, QWidget *b);
|
|---|
| 77 |
|
|---|
| 78 | private slots:
|
|---|
| 79 | void ck_toggled(bool);
|
|---|
| 80 |
|
|---|
| 81 | private:
|
|---|
| 82 | class Private;
|
|---|
| 83 | Private *d;
|
|---|
| 84 | };
|
|---|
| 85 |
|
|---|
| 86 | class ProxyDlg : public ProxyUI
|
|---|
| 87 | {
|
|---|
| 88 | Q_OBJECT
|
|---|
| 89 | public:
|
|---|
| 90 | ProxyDlg(const ProxyItemList &, const QStringList &, int def, QWidget *parent=0, const char *name=0);
|
|---|
| 91 | ~ProxyDlg();
|
|---|
| 92 |
|
|---|
| 93 | signals:
|
|---|
| 94 | void applyList(const ProxyItemList &, int cur);
|
|---|
| 95 |
|
|---|
| 96 | private slots:
|
|---|
| 97 | void proxy_new();
|
|---|
| 98 | void proxy_remove();
|
|---|
| 99 | void cb_activated(int);
|
|---|
| 100 | void qlbx_highlighted(int);
|
|---|
| 101 | void qle_textChanged(const QString &);
|
|---|
| 102 | void doSave();
|
|---|
| 103 |
|
|---|
| 104 | private:
|
|---|
| 105 | class Private;
|
|---|
| 106 | Private *d;
|
|---|
| 107 |
|
|---|
| 108 | void selectCurrent();
|
|---|
| 109 | QString getUniqueName() const;
|
|---|
| 110 | void hookEdit();
|
|---|
| 111 | void unhookEdit();
|
|---|
| 112 | void saveIntoItem(int);
|
|---|
| 113 | };
|
|---|
| 114 |
|
|---|
| 115 | class ProxyChooser : public QWidget
|
|---|
| 116 | {
|
|---|
| 117 | Q_OBJECT
|
|---|
| 118 | public:
|
|---|
| 119 | ProxyChooser(ProxyManager *, QWidget *parent=0, const char *name=0);
|
|---|
| 120 | ~ProxyChooser();
|
|---|
| 121 |
|
|---|
| 122 | int currentItem() const;
|
|---|
| 123 | void setCurrentItem(int);
|
|---|
| 124 | void fixTabbing(QWidget *a, QWidget *b);
|
|---|
| 125 |
|
|---|
| 126 | private slots:
|
|---|
| 127 | void pm_settingsChanged();
|
|---|
| 128 | void doOpen();
|
|---|
| 129 |
|
|---|
| 130 | private:
|
|---|
| 131 | class Private;
|
|---|
| 132 | Private *d;
|
|---|
| 133 |
|
|---|
| 134 | void buildComboBox();
|
|---|
| 135 | };
|
|---|
| 136 |
|
|---|
| 137 | class ProxyItem
|
|---|
| 138 | {
|
|---|
| 139 | public:
|
|---|
| 140 | ProxyItem() {}
|
|---|
| 141 |
|
|---|
| 142 | int id; // used to keep track of 'old' position in a list
|
|---|
| 143 | QString name;
|
|---|
| 144 | QString type;
|
|---|
| 145 | ProxySettings settings;
|
|---|
| 146 | };
|
|---|
| 147 |
|
|---|
| 148 | class ProxyManager : public QObject
|
|---|
| 149 | {
|
|---|
| 150 | Q_OBJECT
|
|---|
| 151 | public:
|
|---|
| 152 | ProxyManager(QObject *parent=0);
|
|---|
| 153 | ~ProxyManager();
|
|---|
| 154 |
|
|---|
| 155 | ProxyChooser *createProxyChooser(QWidget *parent=0);
|
|---|
| 156 | ProxyItemList itemList() const;
|
|---|
| 157 | const ProxyItem & getItem(int) const;
|
|---|
| 158 | int lastEdited() const;
|
|---|
| 159 | void setItemList(const ProxyItemList &);
|
|---|
| 160 | QStringList methodList() const;
|
|---|
| 161 | int findOldIndex(int) const;
|
|---|
| 162 |
|
|---|
| 163 | signals:
|
|---|
| 164 | void settingsChanged();
|
|---|
| 165 |
|
|---|
| 166 | public slots:
|
|---|
| 167 | void openDialog(int);
|
|---|
| 168 |
|
|---|
| 169 | private slots:
|
|---|
| 170 | void pd_applyList(const ProxyItemList &, int cur);
|
|---|
| 171 |
|
|---|
| 172 | private:
|
|---|
| 173 | class Private;
|
|---|
| 174 | Private *d;
|
|---|
| 175 |
|
|---|
| 176 | void assignIds();
|
|---|
| 177 | };
|
|---|
| 178 |
|
|---|
| 179 | #endif
|
|---|