summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/edit.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/edit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index 0c96253..ceac90c 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -1,177 +1,177 @@
1/* 1/*
2 * kPPP: A pppd Front End for the KDE project 2 * kPPP: A pppd Front End for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * Copyright (C) 1997 Bernd Johannes Wuebben 5 * Copyright (C) 1997 Bernd Johannes Wuebben
6 * wuebben@math.cornell.edu 6 * wuebben@math.cornell.edu
7 * 7 *
8 * based on EzPPP: 8 * based on EzPPP:
9 * Copyright (C) 1997 Jay Painter 9 * Copyright (C) 1997 Jay Painter
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public 12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either 13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 14 * version 2 of the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details. 19 * Library General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU Library General Public 21 * You should have received a copy of the GNU Library General Public
22 * License along with this program; if not, write to the Free 22 * License along with this program; if not, write to the Free
23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
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#include <qpe/resource.h>
38 38
39#include "edit.h" 39#include "edit.h"
40#include "pppdata.h" 40#include "pppdata.h"
41#include "iplined.h" 41#include "iplined.h"
42#include "auth.h" 42#include "auth.h"
43 43
44DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount 44DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount
45 , const char *name ) 45 , const char *name )
46 : QWidget(parent, name), _pppdata(pd) 46 : QWidget(parent, name), _pppdata(pd)
47{ 47{
48 const int GRIDROWS = 6; 48 const int GRIDROWS = 6;
49 49
50 QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); 50 QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );
51 51
52 connect_label = new QLabel(tr("Connection name:"), this); 52 connect_label = new QLabel(tr("Connection name:"), this);
53 tl->addWidget(connect_label, 0, 0); 53 tl->addWidget(connect_label, 0, 0);
54 54
55 connectname_l = new QLineEdit(this); 55 connectname_l = new QLineEdit(this);
56// connectname_l->setMaxLength(ACCNAME_SIZE); 56// connectname_l->setMaxLength(ACCNAME_SIZE);
57 tl->addWidget(connectname_l, 0, 1); 57 tl->addWidget(connectname_l, 0, 1);
58 QString tmp = tr("Type in a unique name for this connection"); 58 QString tmp = tr("Type in a unique name for this connection");
59 59
60 QWhatsThis::add(connect_label,tmp); 60 QWhatsThis::add(connect_label,tmp);
61 QWhatsThis::add(connectname_l,tmp); 61 QWhatsThis::add(connectname_l,tmp);
62 62
63 63
64 number_label = new QLabel(tr("Phone number:"), this); 64 number_label = new QLabel(tr("Phone number:"), this);
65 number_label->setAlignment(AlignTop|AlignLeft); 65 number_label->setAlignment(AlignTop|AlignLeft);
66 tl->addWidget(number_label, 1, 0); 66 tl->addWidget(number_label, 1, 0);
67 67
68 QHBoxLayout *lpn = new QHBoxLayout(5); 68 QHBoxLayout *lpn = new QHBoxLayout(5);
69 tl->addLayout(lpn, 1, 1); 69 tl->addLayout(lpn, 1, 1);
70 numbers = new QListBox(this); 70 numbers = new QListBox(this);
71// numbers->setMinimumSize(120, 70); 71// numbers->setMinimumSize(120, 70);
72 lpn->addWidget(numbers); 72 lpn->addWidget(numbers);
73 QVBoxLayout *lpn1 = new QVBoxLayout; 73 QVBoxLayout *lpn1 = new QVBoxLayout;
74 lpn->addLayout(lpn1); 74 lpn->addLayout(lpn1);
75 add = new QPushButton(tr("&Add..."), this); 75 add = new QPushButton(tr("&Add..."), this);
76 del = new QPushButton(tr("&Remove"), this); 76 del = new QPushButton(tr("&Remove"), this);
77 77
78 up = new QPushButton(this); 78 up = new QPushButton(this);
79 up->setPixmap( Resource::loadPixmap("inline/up") ); 79 up->setPixmap( Resource::loadPixmap("up") );
80 down = new QPushButton(this); 80 down = new QPushButton(this);
81 down->setPixmap( Resource::loadPixmap("inline/down") ); 81 down->setPixmap( Resource::loadPixmap("down") );
82 lpn1->addWidget(add); 82 lpn1->addWidget(add);
83 lpn1->addWidget(del); 83 lpn1->addWidget(del);
84 lpn1->addStretch(1); 84 lpn1->addStretch(1);
85 lpn1->addWidget(up); 85 lpn1->addWidget(up);
86 lpn1->addWidget(down); 86 lpn1->addWidget(down);
87 connect(add, SIGNAL(clicked()), 87 connect(add, SIGNAL(clicked()),
88 this, SLOT(addNumber())); 88 this, SLOT(addNumber()));
89 connect(del, SIGNAL(clicked()), 89 connect(del, SIGNAL(clicked()),
90 this, SLOT(delNumber())); 90 this, SLOT(delNumber()));
91 connect(up, SIGNAL(clicked()), 91 connect(up, SIGNAL(clicked()),
92 this, SLOT(upNumber())); 92 this, SLOT(upNumber()));
93 connect(down, SIGNAL(clicked()), 93 connect(down, SIGNAL(clicked()),
94 this, SLOT(downNumber())); 94 this, SLOT(downNumber()));
95 connect(numbers, SIGNAL(highlighted(int)), 95 connect(numbers, SIGNAL(highlighted(int)),
96 this, SLOT(selectionChanged(int))); 96 this, SLOT(selectionChanged(int)));
97 numbersChanged(); 97 numbersChanged();
98 98
99 tmp = tr("<p>Specifies the phone numbers to dial. You\n" 99 tmp = tr("<p>Specifies the phone numbers to dial. You\n"
100 "can supply multiple numbers here, simply\n" 100 "can supply multiple numbers here, simply\n"
101 "click on \"Add\". You can arrange the\n" 101 "click on \"Add\". You can arrange the\n"
102 "order the numbers are tried by using the\n" 102 "order the numbers are tried by using the\n"
103 "arrow buttons.\n\n" 103 "arrow buttons.\n\n"
104 "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"
105 "try the next number and so on"); 105 "try the next number and so on");
106 106
107 QWhatsThis::add(number_label,tmp); 107 QWhatsThis::add(number_label,tmp);
108 QWhatsThis::add(numbers,tmp); 108 QWhatsThis::add(numbers,tmp);
109 109
110 pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); 110 pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this);
111 connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); 111 connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton()));
112 tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); 112 tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter);
113 113
114 // Set defaults if editing an existing connection 114 // Set defaults if editing an existing connection
115 if(!isnewaccount) { 115 if(!isnewaccount) {
116 connectname_l->setText(_pppdata->accname()); 116 connectname_l->setText(_pppdata->accname());
117 117
118 // insert the phone numbers into the listbox 118 // insert the phone numbers into the listbox
119 QString n = _pppdata->phonenumber(); 119 QString n = _pppdata->phonenumber();
120 QString tmp = ""; 120 QString tmp = "";
121 uint idx = 0; 121 uint idx = 0;
122 while(idx != n.length()) { 122 while(idx != n.length()) {
123 if(n[idx] == ':') { 123 if(n[idx] == ':') {
124 if(tmp.length() > 0) 124 if(tmp.length() > 0)
125 numbers->insertItem(tmp); 125 numbers->insertItem(tmp);
126 tmp = ""; 126 tmp = "";
127 } else 127 } else
128 tmp += n[idx]; 128 tmp += n[idx];
129 idx++; 129 idx++;
130 } 130 }
131 if(tmp.length() > 0) 131 if(tmp.length() > 0)
132 numbers->insertItem(tmp); 132 numbers->insertItem(tmp);
133 133
134 } 134 }
135 135
136 numbersChanged(); 136 numbersChanged();
137 tl->activate(); 137 tl->activate();
138} 138}
139 139
140bool DialWidget::save() { 140bool DialWidget::save() {
141 //first check to make sure that the account name is unique! 141 //first check to make sure that the account name is unique!
142 if(connectname_l->text().isEmpty() || 142 if(connectname_l->text().isEmpty() ||
143 !_pppdata->isUniqueAccname(connectname_l->text())) { 143 !_pppdata->isUniqueAccname(connectname_l->text())) {
144 return false; 144 return false;
145 } else { 145 } else {
146 _pppdata->setAccname(connectname_l->text()); 146 _pppdata->setAccname(connectname_l->text());
147 147
148 QString number = ""; 148 QString number = "";
149 for(uint i = 0; i < numbers->count(); i++) { 149 for(uint i = 0; i < numbers->count(); i++) {
150 if(i != 0) 150 if(i != 0)
151 number += ":"; 151 number += ":";
152 number += numbers->text(i); 152 number += numbers->text(i);
153 } 153 }
154 154
155 _pppdata->setPhonenumber(number); 155 _pppdata->setPhonenumber(number);
156 return true; 156 return true;
157 } 157 }
158} 158}
159 159
160 160
161void DialWidget::numbersChanged() { 161void DialWidget::numbersChanged() {
162 int sel = numbers->currentItem(); 162 int sel = numbers->currentItem();
163 163
164 del->setEnabled(sel != -1); 164 del->setEnabled(sel != -1);
165 up->setEnabled(sel != -1 && sel != 0); 165 up->setEnabled(sel != -1 && sel != 0);
166 down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); 166 down->setEnabled(sel != -1 && sel != (int)numbers->count()-1);
167} 167}
168 168
169 169
170void DialWidget::selectionChanged(int) { 170void DialWidget::selectionChanged(int) {
171 numbersChanged(); 171 numbersChanged();
172} 172}
173 173
174 174
175void DialWidget::addNumber() { 175void DialWidget::addNumber() {
176 PhoneNumberDialog dlg(this); 176 PhoneNumberDialog dlg(this);
177 if(dlg.exec()) { 177 if(dlg.exec()) {