Diffstat (limited to 'noncore/settings/networksettings/ppp/edit.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 52 |
1 files changed, 4 insertions, 48 deletions
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index 45d6e4f..b880978 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -25,37 +25,38 @@ | |||
25 | 25 | ||
26 | #include <string.h> | 26 | #include <string.h> |
27 | #include <termios.h> | 27 | #include <termios.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <qbuttongroup.h> | 33 | #include <qbuttongroup.h> |
34 | #include <qvgroupbox.h> | 34 | #include <qvgroupbox.h> |
35 | #include <qhbox.h> | 35 | #include <qhbox.h> |
36 | #include <qdialog.h> | 36 | #include <qdialog.h> |
37 | #include <qpe/resource.h> | ||
37 | 38 | ||
38 | #include "edit.h" | 39 | #include "edit.h" |
39 | #include "pppdata.h" | 40 | #include "pppdata.h" |
40 | #include "iplined.h" | 41 | #include "iplined.h" |
41 | #include "auth.h" | 42 | #include "auth.h" |
42 | 43 | ||
43 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | 44 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount |
44 | , const char *name ) | 45 | , const char *name ) |
45 | : QWidget(parent, name), _pppdata(pd) | 46 | : QWidget(parent, name), _pppdata(pd) |
46 | { | 47 | { |
47 | const int GRIDROWS = 6; | 48 | const int GRIDROWS = 6; |
48 | 49 | ||
49 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); | 50 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); |
50 | 51 | ||
51 | connect_label = new QLabel(tr("Connection name:"), this); | 52 | connect_label = new QLabel(tr("Connection name:"), this); |
52 | tl->addWidget(connect_label, 0, 0); | 53 | tl->addWidget(connect_label, 0, 0); |
53 | 54 | ||
54 | connectname_l = new QLineEdit(this); | 55 | connectname_l = new QLineEdit(this); |
55 | // connectname_l->setMaxLength(ACCNAME_SIZE); | 56 | // connectname_l->setMaxLength(ACCNAME_SIZE); |
56 | tl->addWidget(connectname_l, 0, 1); | 57 | tl->addWidget(connectname_l, 0, 1); |
57 | QString tmp = tr("Type in a unique name for this connection"); | 58 | QString tmp = tr("Type in a unique name for this connection"); |
58 | 59 | ||
59 | QWhatsThis::add(connect_label,tmp); | 60 | QWhatsThis::add(connect_label,tmp); |
60 | QWhatsThis::add(connectname_l,tmp); | 61 | QWhatsThis::add(connectname_l,tmp); |
61 | 62 | ||
@@ -66,29 +67,27 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | |||
66 | 67 | ||
67 | QHBoxLayout *lpn = new QHBoxLayout(5); | 68 | QHBoxLayout *lpn = new QHBoxLayout(5); |
68 | tl->addLayout(lpn, 1, 1); | 69 | tl->addLayout(lpn, 1, 1); |
69 | numbers = new QListBox(this); | 70 | numbers = new QListBox(this); |
70 | // numbers->setMinimumSize(120, 70); | 71 | // numbers->setMinimumSize(120, 70); |
71 | lpn->addWidget(numbers); | 72 | lpn->addWidget(numbers); |
72 | QVBoxLayout *lpn1 = new QVBoxLayout; | 73 | QVBoxLayout *lpn1 = new QVBoxLayout; |
73 | lpn->addLayout(lpn1); | 74 | lpn->addLayout(lpn1); |
74 | add = new QPushButton(tr("&Add..."), this); | 75 | add = new QPushButton(tr("&Add..."), this); |
75 | del = new QPushButton(tr("&Remove"), this); | 76 | del = new QPushButton(tr("&Remove"), this); |
76 | 77 | ||
77 | up = new QPushButton(this); | 78 | up = new QPushButton(this); |
78 | //FIXME: QPixmap pm = BarIcon("up"); | 79 | up->setPixmap( Resource::loadPixmap("inline/up") ); |
79 | // up->setPixmap(pm); | ||
80 | down = new QPushButton(this); | 80 | down = new QPushButton(this); |
81 | //FIXME: pm = BarIcon("down"); | 81 | down->setPixmap( Resource::loadPixmap("inline/down") ); |
82 | // down->setPixmap(pm); | ||
83 | lpn1->addWidget(add); | 82 | lpn1->addWidget(add); |
84 | lpn1->addWidget(del); | 83 | lpn1->addWidget(del); |
85 | lpn1->addStretch(1); | 84 | lpn1->addStretch(1); |
86 | lpn1->addWidget(up); | 85 | lpn1->addWidget(up); |
87 | lpn1->addWidget(down); | 86 | lpn1->addWidget(down); |
88 | connect(add, SIGNAL(clicked()), | 87 | connect(add, SIGNAL(clicked()), |
89 | this, SLOT(addNumber())); | 88 | this, SLOT(addNumber())); |
90 | connect(del, SIGNAL(clicked()), | 89 | connect(del, SIGNAL(clicked()), |
91 | this, SLOT(delNumber())); | 90 | this, SLOT(delNumber())); |
92 | connect(up, SIGNAL(clicked()), | 91 | connect(up, SIGNAL(clicked()), |
93 | this, SLOT(upNumber())); | 92 | this, SLOT(upNumber())); |
94 | connect(down, SIGNAL(clicked()), | 93 | connect(down, SIGNAL(clicked()), |
@@ -99,113 +98,70 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | |||
99 | 98 | ||
100 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" | 99 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" |
101 | "can supply multiple numbers here, simply\n" | 100 | "can supply multiple numbers here, simply\n" |
102 | "click on \"Add\". You can arrange the\n" | 101 | "click on \"Add\". You can arrange the\n" |
103 | "order the numbers are tried by using the\n" | 102 | "order the numbers are tried by using the\n" |
104 | "arrow buttons.\n\n" | 103 | "arrow buttons.\n\n" |
105 | "When a number is busy or fails, <i>kppp</i> will \n" | 104 | "When a number is busy or fails, <i>kppp</i> will \n" |
106 | "try the next number and so on"); | 105 | "try the next number and so on"); |
107 | 106 | ||
108 | QWhatsThis::add(number_label,tmp); | 107 | QWhatsThis::add(number_label,tmp); |
109 | QWhatsThis::add(numbers,tmp); | 108 | QWhatsThis::add(numbers,tmp); |
110 | 109 | ||
111 | auth_l = new QLabel(tr("Authentication:"), this); | ||
112 | tl->addWidget(auth_l, 3, 0); | ||
113 | |||
114 | auth = new QComboBox(this); | ||
115 | auth->insertItem(tr("Script-based")); | ||
116 | auth->insertItem(tr("PAP")); | ||
117 | auth->insertItem(tr("Terminal-based")); | ||
118 | auth->insertItem(tr("CHAP")); | ||
119 | auth->insertItem(tr("PAP/CHAP")); | ||
120 | tl->addWidget(auth, 3, 1); | ||
121 | tmp = tr("<p>Specifies the method used to identify yourself to\n" | ||
122 | "the PPP server. Most universities still use\n" | ||
123 | "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" | ||
124 | "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" | ||
125 | "unsure, contact your ISP.\n" | ||
126 | "\n" | ||
127 | "If you can choose between PAP and CHAP,\n" | ||
128 | "choose CHAP, because it's much safer. If you don't know\n" | ||
129 | "whether PAP or CHAP is right, choose PAP/CHAP."); | ||
130 | |||
131 | QWhatsThis::add(auth_l,tmp); | ||
132 | QWhatsThis::add(auth,tmp); | ||
133 | |||
134 | store_password = new QCheckBox(tr("Store password"), this); | ||
135 | store_password->setChecked(true); | ||
136 | tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight); | ||
137 | QWhatsThis::add(store_password, | ||
138 | tr("<p>When this is turned on, your ISP password\n" | ||
139 | "will be saved in <i>kppp</i>'s config file, so\n" | ||
140 | "you do not need to type it in every time.\n" | ||
141 | "\n" | ||
142 | "<b><font color=\"red\">Warning:</font> your password will be stored as\n" | ||
143 | "plain text in the config file, which is\n" | ||
144 | "readable only to you. Make sure nobody\n" | ||
145 | "gains access to this file!")); | ||
146 | |||
147 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); | 110 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); |
148 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | 111 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); |
149 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | 112 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); |
150 | 113 | ||
151 | // Set defaults if editing an existing connection | 114 | // Set defaults if editing an existing connection |
152 | if(!isnewaccount) { | 115 | if(!isnewaccount) { |
153 | connectname_l->setText(_pppdata->accname()); | 116 | connectname_l->setText(_pppdata->accname()); |
154 | 117 | ||
155 | // insert the phone numbers into the listbox | 118 | // insert the phone numbers into the listbox |
156 | QString n = _pppdata->phonenumber(); | 119 | QString n = _pppdata->phonenumber(); |
157 | QString tmp = ""; | 120 | QString tmp = ""; |
158 | uint idx = 0; | 121 | uint idx = 0; |
159 | while(idx != n.length()) { | 122 | while(idx != n.length()) { |
160 | if(n[idx] == ':') { | 123 | if(n[idx] == ':') { |
161 | if(tmp.length() > 0) | 124 | if(tmp.length() > 0) |
162 | numbers->insertItem(tmp); | 125 | numbers->insertItem(tmp); |
163 | tmp = ""; | 126 | tmp = ""; |
164 | } else | 127 | } else |
165 | tmp += n[idx]; | 128 | tmp += n[idx]; |
166 | idx++; | 129 | idx++; |
167 | } | 130 | } |
168 | if(tmp.length() > 0) | 131 | if(tmp.length() > 0) |
169 | numbers->insertItem(tmp); | 132 | numbers->insertItem(tmp); |
170 | 133 | ||
171 | auth->setCurrentItem(_pppdata->authMethod()); | ||
172 | store_password->setChecked(_pppdata->storePassword()); | ||
173 | } else { | ||
174 | // select PAP/CHAP as default | ||
175 | auth->setCurrentItem(AUTH_PAPCHAP); | ||
176 | } | 134 | } |
177 | 135 | ||
178 | numbersChanged(); | 136 | numbersChanged(); |
179 | tl->activate(); | 137 | tl->activate(); |
180 | } | 138 | } |
181 | 139 | ||
182 | bool DialWidget::save() { | 140 | bool DialWidget::save() { |
183 | //first check to make sure that the account name is unique! | 141 | //first check to make sure that the account name is unique! |
184 | if(connectname_l->text().isEmpty() || | 142 | if(connectname_l->text().isEmpty() || |
185 | !_pppdata->isUniqueAccname(connectname_l->text())) { | 143 | !_pppdata->isUniqueAccname(connectname_l->text())) { |
186 | return false; | 144 | return false; |
187 | } else { | 145 | } else { |
188 | _pppdata->setAccname(connectname_l->text()); | 146 | _pppdata->setAccname(connectname_l->text()); |
189 | 147 | ||
190 | QString number = ""; | 148 | QString number = ""; |
191 | for(uint i = 0; i < numbers->count(); i++) { | 149 | for(uint i = 0; i < numbers->count(); i++) { |
192 | if(i != 0) | 150 | if(i != 0) |
193 | number += ":"; | 151 | number += ":"; |
194 | number += numbers->text(i); | 152 | number += numbers->text(i); |
195 | } | 153 | } |
196 | 154 | ||
197 | _pppdata->setPhonenumber(number); | 155 | _pppdata->setPhonenumber(number); |
198 | _pppdata->setAuthMethod(auth->currentItem()); | ||
199 | _pppdata->setStorePassword(store_password->isChecked()); | ||
200 | return true; | 156 | return true; |
201 | } | 157 | } |
202 | } | 158 | } |
203 | 159 | ||
204 | 160 | ||
205 | void DialWidget::numbersChanged() { | 161 | void DialWidget::numbersChanged() { |
206 | int sel = numbers->currentItem(); | 162 | int sel = numbers->currentItem(); |
207 | 163 | ||
208 | del->setEnabled(sel != -1); | 164 | del->setEnabled(sel != -1); |
209 | up->setEnabled(sel != -1 && sel != 0); | 165 | up->setEnabled(sel != -1 && sel != 0); |
210 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); | 166 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); |
211 | } | 167 | } |