author | llornkcor <llornkcor> | 2002-07-20 02:35:34 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-20 02:35:34 (UTC) |
commit | 8256eec0103a50f80905e71891904a4267754559 (patch) (unidiff) | |
tree | 8dc249ea2db645d38c9ce39a6000e9ee833978b4 /noncore | |
parent | a4a56e27ba0f4fd2bdbc56e20c9e7f4ccc8be535 (diff) | |
download | opie-8256eec0103a50f80905e71891904a4267754559.zip opie-8256eec0103a50f80905e71891904a4267754559.tar.gz opie-8256eec0103a50f80905e71891904a4267754559.tar.bz2 |
fixes and changes.. _should_ remember servers. Still needs work
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 260 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 42 |
2 files changed, 237 insertions, 65 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 9d6356d..9beac94 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -51,6 +51,7 @@ extern "C" { | |||
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qlineedit.h> | 52 | #include <qlineedit.h> |
53 | #include <qregexp.h> | 53 | #include <qregexp.h> |
54 | #include <qlistbox.h> | ||
54 | 55 | ||
55 | #include <unistd.h> | 56 | #include <unistd.h> |
56 | #include <stdlib.h> | 57 | #include <stdlib.h> |
@@ -74,7 +75,7 @@ OpieFtp::OpieFtp( ) | |||
74 | : QMainWindow( ) | 75 | : QMainWindow( ) |
75 | { | 76 | { |
76 | setCaption( tr( "OpieFtp" ) ); | 77 | setCaption( tr( "OpieFtp" ) ); |
77 | 78 | fuckeduphack=FALSE; | |
78 | QGridLayout *layout = new QGridLayout( this ); | 79 | QGridLayout *layout = new QGridLayout( this ); |
79 | layout->setSpacing( 2); | 80 | layout->setSpacing( 2); |
80 | layout->setMargin( 2); | 81 | layout->setMargin( 2); |
@@ -224,6 +225,8 @@ OpieFtp::OpieFtp( ) | |||
224 | UsernameComboBox->setEditable(TRUE); | 225 | UsernameComboBox->setEditable(TRUE); |
225 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); | 226 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); |
226 | 227 | ||
228 | connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this,SLOT( UsernameComboBoxEdited(const QString & ) )); | ||
229 | |||
227 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 230 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
228 | TextLabel2->setText( tr( "Password" ) ); | 231 | TextLabel2->setText( tr( "Password" ) ); |
229 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); | 232 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); |
@@ -231,6 +234,9 @@ OpieFtp::OpieFtp( ) | |||
231 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 234 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
232 | PasswordEdit->setEchoMode(QLineEdit::Password); | 235 | PasswordEdit->setEchoMode(QLineEdit::Password); |
233 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); | 236 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); |
237 | |||
238 | connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this,SLOT( PasswordEditEdited(const QString & ) )); | ||
239 | |||
234 | //PasswordEdit->setFixedWidth(85); | 240 | //PasswordEdit->setFixedWidth(85); |
235 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); | 241 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); |
236 | TextLabel3->setText( tr( "Remote server" ) ); | 242 | TextLabel3->setText( tr( "Remote server" ) ); |
@@ -259,17 +265,28 @@ OpieFtp::OpieFtp( ) | |||
259 | PortSpinBox->setMaxValue(32786); | 265 | PortSpinBox->setMaxValue(32786); |
260 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 266 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
261 | 267 | ||
262 | QPushButton *deleteServerBtn; | 268 | serverListView = new QListBox( tab_3, "ServerListView" ); |
263 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); | 269 | tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5); |
264 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); | ||
265 | |||
266 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | ||
267 | 270 | ||
271 | connect( serverListView, SIGNAL( highlighted( const QString &)), | ||
272 | this,SLOT( serverListClicked( const QString &) ) ); | ||
273 | |||
268 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); | 274 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); |
269 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); | 275 | tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); |
270 | connectServerBtn->setToggleButton(TRUE); | 276 | connectServerBtn->setToggleButton(TRUE); |
271 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); | 277 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); |
272 | 278 | ||
279 | newServerButton= new QPushButton( "Add", tab_3 , "NewServerButton" ); | ||
280 | tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); | ||
281 | connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); | ||
282 | |||
283 | QPushButton *deleteServerBtn; | ||
284 | deleteServerBtn = new QPushButton( "Delete", tab_3 , "OpenButton" ); | ||
285 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); | ||
286 | |||
287 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | ||
288 | |||
289 | |||
273 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 290 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
274 | tabLayout_3->addItem( spacer, 5, 0 ); | 291 | tabLayout_3->addItem( spacer, 5, 0 ); |
275 | 292 | ||
@@ -296,16 +313,13 @@ OpieFtp::OpieFtp( ) | |||
296 | 313 | ||
297 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 314 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
298 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); | 315 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); |
299 | 316 | ProgressBar->setMaximumHeight(10); | |
300 | fillCombos(); | ||
301 | |||
302 | filterStr="*"; | 317 | filterStr="*"; |
303 | b=FALSE; | 318 | b=FALSE; |
304 | populateLocalView(); | 319 | populateLocalView(); |
305 | qDebug("read COnfig"); | 320 | readConfig(); |
306 | readConfig(); | 321 | |
307 | qDebug("Set current item"); | 322 | // ServerComboBox->setCurrentItem(currentServerConfig); |
308 | ServerComboBox->setCurrentItem(currentServerConfig); | ||
309 | 323 | ||
310 | TabWidget->setCurrentPage(2); | 324 | TabWidget->setCurrentPage(2); |
311 | } | 325 | } |
@@ -326,6 +340,10 @@ void OpieFtp::cleanUp() | |||
326 | QFile file( sfile); | 340 | QFile file( sfile); |
327 | if(file.exists()) | 341 | if(file.exists()) |
328 | file.remove(); | 342 | file.remove(); |
343 | Config cfg("opieftp"); | ||
344 | cfg.setGroup("Server"); | ||
345 | cfg.writeEntry("currentServer", currentServerConfig); | ||
346 | |||
329 | exit(0); | 347 | exit(0); |
330 | } | 348 | } |
331 | 349 | ||
@@ -373,10 +391,18 @@ void OpieFtp::newConnection() | |||
373 | 391 | ||
374 | void OpieFtp::serverComboEdited(const QString & edit) | 392 | void OpieFtp::serverComboEdited(const QString & edit) |
375 | { | 393 | { |
376 | if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { | 394 | // if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { |
377 | qDebug("ServerComboEdited"); | 395 | // qDebug("ServerComboEdited"); |
378 | currentServerConfig = -1; | 396 | // // currentServerConfig = -1; |
379 | } | 397 | // } |
398 | } | ||
399 | |||
400 | void OpieFtp::UsernameComboBoxEdited(const QString & use) { | ||
401 | // currentServerConfig = -1; | ||
402 | } | ||
403 | |||
404 | void OpieFtp::PasswordEditEdited(const QString & pass) { | ||
405 | // currentServerConfig = -1; | ||
380 | } | 406 | } |
381 | 407 | ||
382 | void OpieFtp::connectorBtnToggled(bool On) | 408 | void OpieFtp::connectorBtnToggled(bool On) |
@@ -394,7 +420,9 @@ void OpieFtp::connector() | |||
394 | // QCopEnvelope ( "QPE/System", "busy()" ); | 420 | // QCopEnvelope ( "QPE/System", "busy()" ); |
395 | // qApp->processEvents(); | 421 | // qApp->processEvents(); |
396 | currentRemoteDir=remotePath->text(); | 422 | currentRemoteDir=remotePath->text(); |
397 | if(ServerComboBox->currentText().isEmpty()) { | 423 | |
424 | if( ServerComboBox->currentText().isEmpty()) { | ||
425 | |||
398 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); | 426 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); |
399 | TabWidget->setCurrentPage(2); | 427 | TabWidget->setCurrentPage(2); |
400 | ServerComboBox->setFocus(); | 428 | ServerComboBox->setFocus(); |
@@ -402,7 +430,9 @@ void OpieFtp::connector() | |||
402 | connectServerBtn->setText( tr("Connect")); | 430 | connectServerBtn->setText( tr("Connect")); |
403 | return; | 431 | return; |
404 | } | 432 | } |
433 | |||
405 | FtpInit(); | 434 | FtpInit(); |
435 | |||
406 | TabWidget->setCurrentPage(1); | 436 | TabWidget->setCurrentPage(1); |
407 | QString ftp_host = ServerComboBox->currentText(); | 437 | QString ftp_host = ServerComboBox->currentText(); |
408 | QString ftp_user = UsernameComboBox->currentText(); | 438 | QString ftp_user = UsernameComboBox->currentText(); |
@@ -410,15 +440,30 @@ void OpieFtp::connector() | |||
410 | QString port=PortSpinBox->cleanText(); | 440 | QString port=PortSpinBox->cleanText(); |
411 | port.stripWhiteSpace(); | 441 | port.stripWhiteSpace(); |
412 | 442 | ||
443 | Config cfg("opieftp"); | ||
444 | cfg.setGroup("Server"); | ||
445 | int current=cfg.readNumEntry("currentServer", 1); | ||
446 | |||
447 | // if(ftp_host!= cfg.readEntry(QString::number( current))) | ||
448 | // currentServerConfig=-1; | ||
449 | // cfg.setGroup(QString::number(current)); | ||
450 | // if( ftp_user != cfg.readEntry("Username")) | ||
451 | // currentServerConfig=-1; | ||
452 | // if(ftp_pass != cfg.readEntry(cfg.readEntry("Username"))) | ||
453 | // currentServerConfig=-1; | ||
454 | |||
455 | |||
413 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) | 456 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) |
414 | ftp_host=ftp_host.right(ftp_host.length()-6); | 457 | ftp_host=ftp_host.right(ftp_host.length()-6); |
415 | ftp_host+=":"+port; | 458 | ftp_host+=":"+port; |
459 | |||
416 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 460 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
417 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); | 461 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); |
418 | connectServerBtn->setOn(FALSE); | 462 | connectServerBtn->setOn(FALSE); |
419 | connectServerBtn->setText( tr("Connect")); | 463 | connectServerBtn->setText( tr("Connect")); |
420 | return ; | 464 | return ; |
421 | } | 465 | } |
466 | |||
422 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { | 467 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { |
423 | QString msg; | 468 | QString msg; |
424 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); | 469 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); |
@@ -430,9 +475,10 @@ void OpieFtp::connector() | |||
430 | connectServerBtn->setText( tr("Connect")); | 475 | connectServerBtn->setText( tr("Connect")); |
431 | return ; | 476 | return ; |
432 | } | 477 | } |
478 | |||
433 | remoteDirList("/") ; | 479 | remoteDirList("/") ; |
434 | setCaption(ftp_host); | 480 | setCaption(ftp_host); |
435 | if( currentServerConfig == -1) | 481 | if( currentServerConfig == -1) |
436 | writeConfig(); | 482 | writeConfig(); |
437 | connectServerBtn->setText( tr("Disconnect")); | 483 | connectServerBtn->setText( tr("Disconnect")); |
438 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 484 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
@@ -622,7 +668,7 @@ void OpieFtp::populateLocalView() | |||
622 | } | 668 | } |
623 | } | 669 | } |
624 | if(fileL !="./" && fi->exists()) { | 670 | if(fileL !="./" && fi->exists()) { |
625 | item= new QListViewItem( Local_View,fileL, fileDate, fileS ); | 671 | item = new QListViewItem( Local_View,fileL, fileDate, fileS ); |
626 | QPixmap pm; | 672 | QPixmap pm; |
627 | 673 | ||
628 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 674 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
@@ -1149,90 +1195,121 @@ void OpieFtp::readConfig() | |||
1149 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1195 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1150 | 1196 | ||
1151 | // qDebug("Reading %d", currentServerConfig); | 1197 | // qDebug("Reading %d", currentServerConfig); |
1152 | serverComboSelected( currentServerConfig); | 1198 | serverComboSelected( currentServerConfig-1); |
1199 | |||
1153 | } | 1200 | } |
1154 | 1201 | ||
1155 | void OpieFtp::writeConfig() | 1202 | void OpieFtp::writeConfig() |
1156 | { | 1203 | { |
1204 | qDebug("write config"); | ||
1157 | Config cfg("opieftp"); | 1205 | Config cfg("opieftp"); |
1158 | cfg.setGroup("Server"); | 1206 | cfg.setGroup("Server"); |
1207 | |||
1159 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1208 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1209 | |||
1160 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1210 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1211 | |||
1161 | if( currentServerConfig == -1) { | 1212 | if( currentServerConfig == -1) { |
1162 | for (int i = 1; i <= numberOfEntries; i++) { | 1213 | |
1214 | for (int i = 1; i <= numberOfEntries; i++) { | ||
1163 | temp.setNum(i); | 1215 | temp.setNum(i); |
1164 | cfg.setGroup("Server"); | 1216 | cfg.setGroup("Server"); |
1165 | QString tempStr = cfg.readEntry( temp,""); | 1217 | QString tempStr = cfg.readEntry( temp,""); |
1166 | } | 1218 | } |
1219 | |||
1167 | temp.setNum( numberOfEntries + 1); | 1220 | temp.setNum( numberOfEntries + 1); |
1168 | cfg.setGroup("Server"); | 1221 | cfg.setGroup("Server"); |
1222 | |||
1169 | remoteServerStr = cfg.readEntry( temp,""); | 1223 | remoteServerStr = cfg.readEntry( temp,""); |
1224 | |||
1170 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1225 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1171 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1226 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1172 | 1227 | ||
1173 | temp.setNum(numberOfEntries+1); | 1228 | temp.setNum(numberOfEntries+1); |
1174 | cfg.setGroup("Server"); | 1229 | cfg.setGroup("Server"); |
1230 | |||
1175 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1231 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1176 | cfg.writeEntry("currentServer", numberOfEntries+1); | 1232 | cfg.writeEntry("currentServer", numberOfEntries+1); |
1233 | |||
1234 | currentServerConfig = numberOfEntries+1; | ||
1235 | qDebug("setting currentserverconfig to %d", currentServerConfig); | ||
1236 | |||
1177 | cfg.setGroup(temp); | 1237 | cfg.setGroup(temp); |
1238 | if(!newServerName.isEmpty()) | ||
1239 | cfg.writeEntry("ServerName", newServerName); | ||
1240 | |||
1178 | cfg.writeEntry("RemotePath", remotePath->text()); | 1241 | cfg.writeEntry("RemotePath", remotePath->text()); |
1242 | |||
1179 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1243 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1244 | |||
1180 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1245 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1181 | cfg.setGroup("Server"); | 1246 | cfg.setGroup("Server"); |
1247 | |||
1182 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1248 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1183 | 1249 | ||
1184 | } | 1250 | } |
1185 | } | 1251 | } |
1186 | 1252 | ||
1253 | void OpieFtp::clearCombos() { | ||
1254 | qDebug("clearing"); | ||
1255 | ServerComboBox->clear(); | ||
1256 | UsernameComboBox->clear(); | ||
1257 | PasswordEdit->clear(); | ||
1258 | serverListView->clear(); | ||
1259 | } | ||
1260 | |||
1261 | |||
1187 | void OpieFtp::fillCombos() | 1262 | void OpieFtp::fillCombos() |
1188 | { | 1263 | { |
1264 | clearCombos(); | ||
1265 | |||
1189 | Config cfg("opieftp"); | 1266 | Config cfg("opieftp"); |
1190 | cfg.setGroup("Server"); | 1267 | cfg.setGroup("Server"); |
1191 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1268 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1192 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1269 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1270 | |||
1193 | for (int i = 1; i <= numberOfEntries; i++) { | 1271 | for (int i = 1; i <= numberOfEntries; i++) { |
1194 | temp.setNum(i); | 1272 | temp.setNum(i); |
1195 | qDebug(temp); | 1273 | qDebug(temp); |
1196 | cfg.setGroup("Server"); | 1274 | cfg.setGroup("Server"); |
1197 | remoteServerStr = cfg.readEntry( temp,""); | 1275 | remoteServerStr = cfg.readEntry( temp,""); |
1198 | qDebug( remoteServerStr); | 1276 | qDebug( remoteServerStr); |
1277 | |||
1199 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1278 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1200 | port = remoteServerStr.right( divider - 1); | 1279 | port = remoteServerStr.right( divider - 1); |
1201 | bool ok; | 1280 | bool ok; |
1202 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1281 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1203 | 1282 | ||
1204 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1283 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1205 | qDebug( remoteServerStr); | 1284 | qDebug( "remote server string "+remoteServerStr); |
1206 | ServerComboBox->insertItem( remoteServerStr ); | 1285 | ServerComboBox->insertItem( remoteServerStr ); |
1207 | // cfg.setGroup(temp); | ||
1208 | 1286 | ||
1209 | // remotePathStr = cfg.readEntry(remoteServer,""); | 1287 | cfg.setGroup(temp); |
1210 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); | ||
1211 | // port = remoteServer.right( divider+1); | ||
1212 | // PortSpinBox->setValue( port); | ||
1213 | 1288 | ||
1214 | // remoteServer = remoteServer.left(divider - 1); | 1289 | username = cfg.readEntry(temp); |
1215 | // remotePath->setText( remotePathStr); | 1290 | UsernameComboBox->insertItem(username); |
1291 | password = cfg.readEntryCrypt(username,""); | ||
1292 | PasswordEdit->setText(password); | ||
1216 | 1293 | ||
1217 | // username = cfg.readEntry(temp); | 1294 | serverListView->insertItem( cfg.readEntry("ServerName")); |
1218 | // UsernameComboBox->insertItem(username); | ||
1219 | // password = cfg.readEntryCrypt(username,""); | ||
1220 | // PasswordEdit->setText(password); | ||
1221 | } | 1295 | } |
1222 | } | 1296 | } |
1223 | 1297 | ||
1224 | 1298 | ||
1225 | void OpieFtp::serverComboSelected(int index) | 1299 | void OpieFtp::serverComboSelected(int index) |
1226 | { | 1300 | { |
1227 | currentServerConfig = index; | 1301 | currentServerConfig = index+1; |
1302 | qDebug("server combo selected %d", index+1); | ||
1228 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1303 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1229 | // remoteServerStr = ServerComboBox->text(index); | 1304 | // remoteServerStr = ServerComboBox->text(index); |
1305 | |||
1230 | Config cfg("opieftp"); | 1306 | Config cfg("opieftp"); |
1231 | cfg.setGroup("Server"); | 1307 | cfg.setGroup("Server"); |
1232 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1308 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1233 | 1309 | ||
1234 | temp.setNum(index); | 1310 | temp.setNum(index+1); |
1235 | remoteServerStr = cfg.readEntry( temp,""); | 1311 | remoteServerStr = cfg.readEntry( temp,""); |
1312 | |||
1236 | qDebug("Group" +temp); | 1313 | qDebug("Group" +temp); |
1237 | cfg.setGroup(temp); | 1314 | cfg.setGroup(temp); |
1238 | // qDebug(temp); | 1315 | // qDebug(temp); |
@@ -1241,7 +1318,9 @@ void OpieFtp::serverComboSelected(int index) | |||
1241 | bool ok; | 1318 | bool ok; |
1242 | int portInt = port.toInt(&ok,10); | 1319 | int portInt = port.toInt(&ok,10); |
1243 | if( portInt == 0) portInt = 21; | 1320 | if( portInt == 0) portInt = 21; |
1244 | 1321 | ||
1322 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); | ||
1323 | |||
1245 | PortSpinBox->setValue( portInt); | 1324 | PortSpinBox->setValue( portInt); |
1246 | 1325 | ||
1247 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1326 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
@@ -1256,32 +1335,76 @@ void OpieFtp::serverComboSelected(int index) | |||
1256 | 1335 | ||
1257 | cfg.setGroup("Server"); | 1336 | cfg.setGroup("Server"); |
1258 | temp.sprintf("%d",currentServerConfig); | 1337 | temp.sprintf("%d",currentServerConfig); |
1259 | cfg.writeEntry("currentServer", temp); | 1338 | cfg.writeEntry("currentServer", temp); |
1339 | |||
1340 | fuckeduphack = TRUE; | ||
1341 | serverListView->setCurrentItem( index); | ||
1342 | fuckeduphack=FALSE; | ||
1343 | qDebug("server list set selected %d",index); | ||
1260 | update(); | 1344 | update(); |
1261 | } | 1345 | } |
1262 | // UsernameComboBox->lineEdit()->setText("root"); | ||
1263 | // PasswordEdit->setText( tr( "" ) ); | ||
1264 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | ||
1265 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); | ||
1266 | // PortSpinBox->setValue( 4242); | ||
1267 | 1346 | ||
1268 | void OpieFtp::deleteServer() | 1347 | void OpieFtp::deleteServer() |
1269 | { | 1348 | { |
1270 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1349 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; |
1271 | remoteServerStr = ServerComboBox->currentText( ); | 1350 | remoteServerStr = ServerComboBox->currentText( ); |
1272 | username = UsernameComboBox->currentText(); | 1351 | username = UsernameComboBox->currentText(); |
1352 | servername=serverListView->currentText(); | ||
1353 | |||
1273 | Config cfg("opieftp"); | 1354 | Config cfg("opieftp"); |
1274 | cfg.setGroup("Server"); | 1355 | cfg.setGroup("Server"); |
1356 | QString tempname; | ||
1275 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1357 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1276 | for (int i = 0; i <= numberOfEntries; i++) { | 1358 | |
1277 | temp.setNum(i+1); | 1359 | for (int i = 1; i <= numberOfEntries; i++) { |
1278 | cfg.setGroup("Server"); | 1360 | temp.setNum(i); |
1279 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 | 1361 | // cfg.setGroup("Server"); |
1280 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 | 1362 | cfg.setGroup(QString::number(i)); |
1281 | && !remoteServerStr.isEmpty()) { | 1363 | tempname=cfg.readEntry( "ServerName",""); |
1282 | qDebug(temp); | 1364 | |
1365 | if( tempname.find( servername,0,TRUE) != -1 ) { | ||
1366 | // servername.find( cfg.readEntry("ServerName")) != -1 && | ||
1367 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && | ||
1368 | // username.find( cfg.readEntry("Username")) != -1) { | ||
1369 | |||
1370 | serverListView->removeItem(i); | ||
1371 | |||
1372 | qDebug("OK DELETE "+tempname); | ||
1373 | cfg.removeEntry(QString::number(i)); | ||
1374 | for ( i; i <= numberOfEntries; i++) { | ||
1375 | cfg.setGroup("Server"); | ||
1376 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); | ||
1377 | |||
1378 | cfg.setGroup(QString::number(i+1)); //get next server config | ||
1379 | servername=cfg.readEntry("ServerName"); | ||
1380 | remoteServerStr=cfg.readEntry("RemotePath"); | ||
1381 | username=cfg.readEntry("Username"); | ||
1382 | password=cfg.readEntryCrypt( username); | ||
1383 | |||
1384 | cfg.setGroup(QString::number(i)); | ||
1385 | |||
1386 | cfg.writeEntry("RemotePath", remoteServerStr); | ||
1387 | cfg.writeEntry("ServerName", servername); | ||
1388 | cfg.writeEntry("Username", username); | ||
1389 | cfg.writeEntryCrypt( username, password); | ||
1390 | |||
1391 | } | ||
1392 | cfg.setGroup("Server"); | ||
1393 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 )); | ||
1283 | } | 1394 | } |
1284 | } | 1395 | } |
1396 | cfg.setGroup(QString::number(numberOfEntries)); | ||
1397 | cfg.removeEntry("Server"); | ||
1398 | cfg.removeEntry("RemotePath"); | ||
1399 | cfg.removeEntry("ServerName"); | ||
1400 | username=cfg.readEntry("Username"); | ||
1401 | cfg.removeEntry("Username"); | ||
1402 | cfg.removeEntry(username); | ||
1403 | |||
1404 | currentServerConfig=currentServerConfig-1; | ||
1405 | |||
1406 | fillCombos(); | ||
1407 | update(); | ||
1285 | } | 1408 | } |
1286 | 1409 | ||
1287 | void OpieFtp::upDir() | 1410 | void OpieFtp::upDir() |
@@ -1345,3 +1468,36 @@ void OpieFtp::doAbout() { | |||
1345 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" | 1468 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" |
1346 | "and is licensed by the GPL"); | 1469 | "and is licensed by the GPL"); |
1347 | } | 1470 | } |
1471 | |||
1472 | void OpieFtp::NewServer() { | ||
1473 | InputDialog *fileDlg; | ||
1474 | fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0); | ||
1475 | fileDlg->exec(); | ||
1476 | Config cfg("opieftp"); | ||
1477 | if( fileDlg->result() == 1 ) { | ||
1478 | newServerName = fileDlg->LineEdit1->text(); | ||
1479 | for(int i=1;i<serverListView->count();i++) { | ||
1480 | cfg.setGroup( QString::number(i)); | ||
1481 | if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) { | ||
1482 | QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken")); | ||
1483 | return; | ||
1484 | } | ||
1485 | } | ||
1486 | currentServerConfig =-1; | ||
1487 | writeConfig(); | ||
1488 | serverListView->insertItem( newServerName ); | ||
1489 | serverListView->setCurrentItem( serverListView->count()); | ||
1490 | } | ||
1491 | } | ||
1492 | |||
1493 | void OpieFtp::serverListClicked( const QString &item) { | ||
1494 | if(item.isEmpty()) return; | ||
1495 | Config cfg("opieftp"); | ||
1496 | qDebug("highltined "+item); | ||
1497 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | ||
1498 | for (int i = 1; i <= numberOfEntries; i++) { | ||
1499 | cfg.setGroup(QString::number(i)); | ||
1500 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) | ||
1501 | serverComboSelected(i-1); | ||
1502 | } | ||
1503 | } | ||
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h index ad36b1d..2aa691a 100644 --- a/noncore/net/opieftp/opieftp.h +++ b/noncore/net/opieftp/opieftp.h | |||
@@ -24,7 +24,7 @@ class QHBoxLayout; | |||
24 | class QGridLayout; | 24 | class QGridLayout; |
25 | class QComboBox; | 25 | class QComboBox; |
26 | class QListView; | 26 | class QListView; |
27 | class QListviewItem; | 27 | class QListViewItem; |
28 | class QLabel; | 28 | class QLabel; |
29 | class QProgressBar; | 29 | class QProgressBar; |
30 | class QSpinBox; | 30 | class QSpinBox; |
@@ -34,11 +34,11 @@ class QPEToolBar; | |||
34 | class QPEMenuBar; | 34 | class QPEMenuBar; |
35 | class QPopupMenu; | 35 | class QPopupMenu; |
36 | class QFile; | 36 | class QFile; |
37 | class QListViewItem; | ||
38 | class QLineEdit; | 37 | class QLineEdit; |
39 | class QPushButton; | 38 | class QPushButton; |
40 | class QToolButton; | 39 | class QToolButton; |
41 | class QStringList; | 40 | class QStringList; |
41 | class QListBox; | ||
42 | 42 | ||
43 | class OpieFtp : public QMainWindow | 43 | class OpieFtp : public QMainWindow |
44 | { | 44 | { |
@@ -51,6 +51,7 @@ public: | |||
51 | QTabWidget *TabWidget; | 51 | QTabWidget *TabWidget; |
52 | QWidget *tab, *tab_2, *tab_3; | 52 | QWidget *tab, *tab_2, *tab_3; |
53 | QListView *Local_View, *Remote_View; | 53 | QListView *Local_View, *Remote_View; |
54 | QListBox *serverListView; | ||
54 | 55 | ||
55 | QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo; | 56 | QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo; |
56 | QLineEdit *PasswordEdit, *remotePath; | 57 | QLineEdit *PasswordEdit, *remotePath; |
@@ -61,7 +62,7 @@ public: | |||
61 | QString currentRemoteDir; | 62 | QString currentRemoteDir; |
62 | QString filterStr; | 63 | QString filterStr; |
63 | QListViewItem * item; | 64 | QListViewItem * item; |
64 | QPushButton *connectServerBtn;// | 65 | QPushButton *connectServerBtn, *newServerButton;// |
65 | QToolButton *cdUpButton, *homeButton, *docButton; | 66 | QToolButton *cdUpButton, *homeButton, *docButton; |
66 | bool b; | 67 | bool b; |
67 | int currentServerConfig; | 68 | int currentServerConfig; |
@@ -70,7 +71,11 @@ protected slots: | |||
70 | void homeButtonPushed(); | 71 | void homeButtonPushed(); |
71 | void docButtonPushed(); | 72 | void docButtonPushed(); |
72 | void doAbout(); | 73 | void doAbout(); |
74 | |||
73 | void serverComboEdited(const QString & ); | 75 | void serverComboEdited(const QString & ); |
76 | void UsernameComboBoxEdited(const QString & ); | ||
77 | void PasswordEditEdited(const QString & ); | ||
78 | |||
74 | void showLocalMenu( QListViewItem *); | 79 | void showLocalMenu( QListViewItem *); |
75 | void showRemoteMenu( QListViewItem *); | 80 | void showRemoteMenu( QListViewItem *); |
76 | void doLocalCd(); | 81 | void doLocalCd(); |
@@ -93,25 +98,36 @@ protected slots: | |||
93 | void localDelete(); | 98 | void localDelete(); |
94 | void remoteMakDir(); | 99 | void remoteMakDir(); |
95 | void remoteDelete(); | 100 | void remoteDelete(); |
101 | |||
96 | bool remoteDirList(const QString &); | 102 | bool remoteDirList(const QString &); |
97 | bool remoteChDir(const QString &); | 103 | bool remoteChDir(const QString &); |
104 | |||
98 | void tabChanged(QWidget*); | 105 | void tabChanged(QWidget*); |
99 | void cleanUp(); | 106 | void cleanUp(); |
107 | |||
100 | void remoteRename(); | 108 | void remoteRename(); |
101 | void localRename(); | 109 | void localRename(); |
110 | |||
102 | void currentPathComboChanged(); | 111 | void currentPathComboChanged(); |
103 | void currentPathComboActivated(const QString &); | 112 | void currentPathComboActivated(const QString &); |
104 | void switchToLocalTab(); | 113 | void switchToLocalTab(); |
105 | void switchToRemoteTab(); | 114 | void switchToRemoteTab(); |
106 | void switchToConfigTab(); | 115 | void switchToConfigTab(); |
107 | void fillCombos(); | 116 | |
108 | void fillRemoteCombo(const QString&); | 117 | void fillCombos(); |
109 | void fillCombo(const QString &); | 118 | void clearCombos(); |
110 | void serverComboSelected(int); | 119 | void fillRemoteCombo(const QString&); |
111 | void deleteServer(); | 120 | void fillCombo(const QString &); |
112 | void connectorBtnToggled(bool); | 121 | void serverComboSelected(int); |
122 | void deleteServer(); | ||
123 | void connectorBtnToggled(bool); | ||
124 | void NewServer(); | ||
125 | void serverListClicked( const QString &); | ||
126 | |||
113 | protected: | 127 | protected: |
128 | bool fuckeduphack; | ||
114 | QStringList remoteDirPathStringList, localDirPathStringList; | 129 | QStringList remoteDirPathStringList, localDirPathStringList; |
130 | QString newServerName; | ||
115 | void nullifyCallBack(); | 131 | void nullifyCallBack(); |
116 | QGridLayout* tabLayout; | 132 | QGridLayout* tabLayout; |
117 | QGridLayout* tabLayout_2; | 133 | QGridLayout* tabLayout_2; |