-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 3d97ecb..292cc9d 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -1255,257 +1255,257 @@ void OpieFtp::writeConfig() | |||
1255 | cfg.setGroup("Server"); | 1255 | cfg.setGroup("Server"); |
1256 | 1256 | ||
1257 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1257 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1258 | 1258 | ||
1259 | } | 1259 | } |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | void OpieFtp::clearCombos() { | 1262 | void OpieFtp::clearCombos() { |
1263 | qDebug("clearing"); | 1263 | qDebug("clearing"); |
1264 | ServerComboBox->clear(); | 1264 | ServerComboBox->clear(); |
1265 | UsernameComboBox->clear(); | 1265 | UsernameComboBox->clear(); |
1266 | PasswordEdit->clear(); | 1266 | PasswordEdit->clear(); |
1267 | serverListView->clear(); | 1267 | serverListView->clear(); |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | 1270 | ||
1271 | void OpieFtp::fillCombos() | 1271 | void OpieFtp::fillCombos() |
1272 | { | 1272 | { |
1273 | clearCombos(); | 1273 | clearCombos(); |
1274 | 1274 | ||
1275 | Config cfg("opieftp"); | 1275 | Config cfg("opieftp"); |
1276 | cfg.setGroup("Server"); | 1276 | cfg.setGroup("Server"); |
1277 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1277 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1278 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1278 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1279 | 1279 | ||
1280 | for (int i = 1; i <= numberOfEntries; i++) { | 1280 | for (int i = 1; i <= numberOfEntries; i++) { |
1281 | temp.setNum(i); | 1281 | temp.setNum(i); |
1282 | qDebug(temp); | 1282 | qDebug(temp); |
1283 | cfg.setGroup("Server"); | 1283 | cfg.setGroup("Server"); |
1284 | remoteServerStr = cfg.readEntry( temp,""); | 1284 | remoteServerStr = cfg.readEntry( temp,""); |
1285 | qDebug( remoteServerStr); | 1285 | qDebug( remoteServerStr); |
1286 | 1286 | ||
1287 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1287 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1288 | port = remoteServerStr.right( divider - 1); | 1288 | port = remoteServerStr.right( divider - 1); |
1289 | bool ok; | 1289 | bool ok; |
1290 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1290 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1291 | 1291 | ||
1292 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1292 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1293 | qDebug( "remote server string "+remoteServerStr); | 1293 | qDebug( "remote server string "+remoteServerStr); |
1294 | ServerComboBox->insertItem( remoteServerStr ); | 1294 | ServerComboBox->insertItem( remoteServerStr ); |
1295 | 1295 | ||
1296 | cfg.setGroup(temp); | 1296 | cfg.setGroup(temp); |
1297 | 1297 | ||
1298 | username = cfg.readEntry(temp); | 1298 | username = cfg.readEntry(temp); |
1299 | UsernameComboBox->insertItem(username); | 1299 | UsernameComboBox->insertItem(username); |
1300 | password = cfg.readEntryCrypt(username,""); | 1300 | password = cfg.readEntryCrypt(username,""); |
1301 | PasswordEdit->setText(password); | 1301 | PasswordEdit->setText(password); |
1302 | 1302 | ||
1303 | serverListView->insertItem( cfg.readEntry("ServerName")); | 1303 | serverListView->insertItem( cfg.readEntry("ServerName")); |
1304 | } | 1304 | } |
1305 | } | 1305 | } |
1306 | 1306 | ||
1307 | 1307 | ||
1308 | void OpieFtp::serverComboSelected(int index) | 1308 | void OpieFtp::serverComboSelected(int index) |
1309 | { | 1309 | { |
1310 | currentServerConfig = index+1; | 1310 | currentServerConfig = index+1; |
1311 | qDebug("server combo selected %d", index+1); | 1311 | qDebug("server combo selected %d", index+1); |
1312 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1312 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1313 | // remoteServerStr = ServerComboBox->text(index); | 1313 | // remoteServerStr = ServerComboBox->text(index); |
1314 | 1314 | ||
1315 | Config cfg("opieftp"); | 1315 | Config cfg("opieftp"); |
1316 | cfg.setGroup("Server"); | 1316 | cfg.setGroup("Server"); |
1317 | // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1317 | // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1318 | 1318 | ||
1319 | temp.setNum(index+1); | 1319 | temp.setNum(index+1); |
1320 | remoteServerStr = cfg.readEntry( temp,""); | 1320 | remoteServerStr = cfg.readEntry( temp,""); |
1321 | 1321 | ||
1322 | qDebug("Group" +temp); | 1322 | qDebug("Group" +temp); |
1323 | cfg.setGroup(temp); | 1323 | cfg.setGroup(temp); |
1324 | // qDebug(temp); | 1324 | // qDebug(temp); |
1325 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1325 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1326 | port = remoteServerStr.right( divider - 1); | 1326 | port = remoteServerStr.right( divider - 1); |
1327 | bool ok; | 1327 | bool ok; |
1328 | int portInt = port.toInt(&ok,10); | 1328 | int portInt = port.toInt(&ok,10); |
1329 | if( portInt == 0) portInt = 21; | 1329 | if( portInt == 0) portInt = 21; |
1330 | 1330 | ||
1331 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); | 1331 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); |
1332 | 1332 | ||
1333 | PortSpinBox->setValue( portInt); | 1333 | PortSpinBox->setValue( portInt); |
1334 | 1334 | ||
1335 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1335 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
1336 | 1336 | ||
1337 | username = cfg.readEntry("Username", "anonymous"); | 1337 | username = cfg.readEntry("Username", "anonymous"); |
1338 | UsernameComboBox->lineEdit()->setText(username); | 1338 | UsernameComboBox->lineEdit()->setText(username); |
1339 | qDebug(username); | 1339 | qDebug(username); |
1340 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); | 1340 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); |
1341 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); | 1341 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); |
1342 | // UsernameComboBox | 1342 | // UsernameComboBox |
1343 | // PasswordEdit | 1343 | // PasswordEdit |
1344 | 1344 | ||
1345 | cfg.setGroup("Server"); | 1345 | cfg.setGroup("Server"); |
1346 | temp.sprintf("%d",currentServerConfig); | 1346 | temp.sprintf("%d",currentServerConfig); |
1347 | cfg.writeEntry("currentServer", temp); | 1347 | cfg.writeEntry("currentServer", temp); |
1348 | 1348 | ||
1349 | fuckeduphack = TRUE; | 1349 | fuckeduphack = TRUE; |
1350 | serverListView->setCurrentItem( index); | 1350 | serverListView->setCurrentItem( index); |
1351 | fuckeduphack=FALSE; | 1351 | fuckeduphack=FALSE; |
1352 | qDebug("server list set selected %d",index); | 1352 | qDebug("server list set selected %d",index); |
1353 | update(); | 1353 | update(); |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | void OpieFtp::deleteServer() | 1356 | void OpieFtp::deleteServer() |
1357 | { | 1357 | { |
1358 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; | 1358 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; |
1359 | remoteServerStr = ServerComboBox->currentText( ); | 1359 | remoteServerStr = ServerComboBox->currentText( ); |
1360 | username = UsernameComboBox->currentText(); | 1360 | username = UsernameComboBox->currentText(); |
1361 | servername=serverListView->currentText(); | 1361 | servername=serverListView->currentText(); |
1362 | 1362 | ||
1363 | Config cfg("opieftp"); | 1363 | Config cfg("opieftp"); |
1364 | cfg.setGroup("Server"); | 1364 | cfg.setGroup("Server"); |
1365 | QString tempname; | 1365 | QString tempname; |
1366 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1366 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1367 | 1367 | ||
1368 | for (int i = 1; i <= numberOfEntries; i++) { | 1368 | for (int i = 1; i <= numberOfEntries; i++) { |
1369 | temp.setNum(i); | 1369 | temp.setNum(i); |
1370 | // cfg.setGroup("Server"); | 1370 | // cfg.setGroup("Server"); |
1371 | cfg.setGroup(QString::number(i)); | 1371 | cfg.setGroup(QString::number(i)); |
1372 | tempname=cfg.readEntry( "ServerName",""); | 1372 | tempname=cfg.readEntry( "ServerName",""); |
1373 | 1373 | ||
1374 | if( tempname.find( servername,0,TRUE) != -1 ) { | 1374 | if( tempname.find( servername,0,TRUE) != -1 ) { |
1375 | // servername.find( cfg.readEntry("ServerName")) != -1 && | 1375 | // servername.find( cfg.readEntry("ServerName")) != -1 && |
1376 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && | 1376 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && |
1377 | // username.find( cfg.readEntry("Username")) != -1) { | 1377 | // username.find( cfg.readEntry("Username")) != -1) { |
1378 | 1378 | ||
1379 | serverListView->removeItem(i); | 1379 | serverListView->removeItem(i); |
1380 | 1380 | ||
1381 | qDebug("OK DELETE "+tempname); | 1381 | qDebug("OK DELETE "+tempname); |
1382 | cfg.removeEntry(QString::number(i)); | 1382 | cfg.removeEntry(QString::number(i)); |
1383 | for ( i; i <= numberOfEntries; i++) { | 1383 | for ( ; i <= numberOfEntries; i++) { |
1384 | cfg.setGroup("Server"); | 1384 | cfg.setGroup("Server"); |
1385 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); | 1385 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); |
1386 | 1386 | ||
1387 | cfg.setGroup(QString::number(i+1)); //get next server config | 1387 | cfg.setGroup(QString::number(i+1)); //get next server config |
1388 | servername=cfg.readEntry("ServerName"); | 1388 | servername=cfg.readEntry("ServerName"); |
1389 | remoteServerStr=cfg.readEntry("RemotePath"); | 1389 | remoteServerStr=cfg.readEntry("RemotePath"); |
1390 | username=cfg.readEntry("Username"); | 1390 | username=cfg.readEntry("Username"); |
1391 | password=cfg.readEntryCrypt( username); | 1391 | password=cfg.readEntryCrypt( username); |
1392 | 1392 | ||
1393 | cfg.setGroup(QString::number(i)); | 1393 | cfg.setGroup(QString::number(i)); |
1394 | 1394 | ||
1395 | cfg.writeEntry("RemotePath", remoteServerStr); | 1395 | cfg.writeEntry("RemotePath", remoteServerStr); |
1396 | cfg.writeEntry("ServerName", servername); | 1396 | cfg.writeEntry("ServerName", servername); |
1397 | cfg.writeEntry("Username", username); | 1397 | cfg.writeEntry("Username", username); |
1398 | cfg.writeEntryCrypt( username, password); | 1398 | cfg.writeEntryCrypt( username, password); |
1399 | 1399 | ||
1400 | } | 1400 | } |
1401 | cfg.setGroup("Server"); | 1401 | cfg.setGroup("Server"); |
1402 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 )); | 1402 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 )); |
1403 | } | 1403 | } |
1404 | } | 1404 | } |
1405 | cfg.setGroup(QString::number(numberOfEntries)); | 1405 | cfg.setGroup(QString::number(numberOfEntries)); |
1406 | cfg.removeEntry("Server"); | 1406 | cfg.removeEntry("Server"); |
1407 | cfg.removeEntry("RemotePath"); | 1407 | cfg.removeEntry("RemotePath"); |
1408 | cfg.removeEntry("ServerName"); | 1408 | cfg.removeEntry("ServerName"); |
1409 | username=cfg.readEntry("Username"); | 1409 | username=cfg.readEntry("Username"); |
1410 | cfg.removeEntry("Username"); | 1410 | cfg.removeEntry("Username"); |
1411 | cfg.removeEntry(username); | 1411 | cfg.removeEntry(username); |
1412 | 1412 | ||
1413 | currentServerConfig=currentServerConfig-1; | 1413 | currentServerConfig=currentServerConfig-1; |
1414 | 1414 | ||
1415 | fillCombos(); | 1415 | fillCombos(); |
1416 | update(); | 1416 | update(); |
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | void OpieFtp::upDir() | 1419 | void OpieFtp::upDir() |
1420 | { | 1420 | { |
1421 | if (TabWidget->currentPageIndex() == 0) { | 1421 | if (TabWidget->currentPageIndex() == 0) { |
1422 | QString current = currentDir.canonicalPath(); | 1422 | QString current = currentDir.canonicalPath(); |
1423 | QDir dir(current); | 1423 | QDir dir(current); |
1424 | dir.cdUp(); | 1424 | dir.cdUp(); |
1425 | current = dir.canonicalPath(); | 1425 | current = dir.canonicalPath(); |
1426 | chdir( current.latin1() ); | 1426 | chdir( current.latin1() ); |
1427 | currentDir.cd( current, TRUE); | 1427 | currentDir.cd( current, TRUE); |
1428 | populateLocalView(); | 1428 | populateLocalView(); |
1429 | update(); | 1429 | update(); |
1430 | } else { | 1430 | } else { |
1431 | if( FtpCDUp( conn) == 0) { | 1431 | if( FtpCDUp( conn) == 0) { |
1432 | QString msg; | 1432 | QString msg; |
1433 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 1433 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
1434 | msg.replace(QRegExp(":"),"\n"); | 1434 | msg.replace(QRegExp(":"),"\n"); |
1435 | QMessageBox::message(tr("Note"),msg); | 1435 | QMessageBox::message(tr("Note"),msg); |
1436 | // qDebug(msg); | 1436 | // qDebug(msg); |
1437 | } | 1437 | } |
1438 | char path[256]; | 1438 | char path[256]; |
1439 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 1439 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
1440 | QString msg; | 1440 | QString msg; |
1441 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 1441 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
1442 | msg.replace(QRegExp(":"),"\n"); | 1442 | msg.replace(QRegExp(":"),"\n"); |
1443 | QMessageBox::message(tr("Note"),msg); | 1443 | QMessageBox::message(tr("Note"),msg); |
1444 | // qDebug(msg); | 1444 | // qDebug(msg); |
1445 | } | 1445 | } |
1446 | currentRemoteDir=path; | 1446 | currentRemoteDir=path; |
1447 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1447 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1448 | if(currentRemoteDir.right(1) !="/") | 1448 | if(currentRemoteDir.right(1) !="/") |
1449 | currentRemoteDir +="/"; | 1449 | currentRemoteDir +="/"; |
1450 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 1450 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
1451 | fillRemoteCombo( (const QString &)currentRemoteDir); | 1451 | fillRemoteCombo( (const QString &)currentRemoteDir); |
1452 | 1452 | ||
1453 | } | 1453 | } |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | void OpieFtp::docButtonPushed() { | 1456 | void OpieFtp::docButtonPushed() { |
1457 | QString current = QPEApplication::documentDir(); | 1457 | QString current = QPEApplication::documentDir(); |
1458 | chdir( current.latin1() ); | 1458 | chdir( current.latin1() ); |
1459 | currentDir.cd( current, TRUE); | 1459 | currentDir.cd( current, TRUE); |
1460 | populateLocalView(); | 1460 | populateLocalView(); |
1461 | update(); | 1461 | update(); |
1462 | 1462 | ||
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | void OpieFtp::homeButtonPushed() { | 1465 | void OpieFtp::homeButtonPushed() { |
1466 | QString current = QDir::homeDirPath(); | 1466 | QString current = QDir::homeDirPath(); |
1467 | chdir( current.latin1() ); | 1467 | chdir( current.latin1() ); |
1468 | currentDir.cd( current, TRUE); | 1468 | currentDir.cd( current, TRUE); |
1469 | populateLocalView(); | 1469 | populateLocalView(); |
1470 | update(); | 1470 | update(); |
1471 | } | 1471 | } |
1472 | 1472 | ||
1473 | void OpieFtp::doAbout() { | 1473 | void OpieFtp::doAbout() { |
1474 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" | 1474 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" |
1475 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1475 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1476 | "and uses ftplib copyright 1996-2000\n" | 1476 | "and uses ftplib copyright 1996-2000\n" |
1477 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" | 1477 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" |
1478 | "and is licensed by the GPL"); | 1478 | "and is licensed by the GPL"); |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | void OpieFtp::NewServer() { | 1481 | void OpieFtp::NewServer() { |
1482 | InputDialog *fileDlg; | 1482 | InputDialog *fileDlg; |
1483 | fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0); | 1483 | fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0); |
1484 | fileDlg->exec(); | 1484 | fileDlg->exec(); |
1485 | Config cfg("opieftp"); | 1485 | Config cfg("opieftp"); |
1486 | if( fileDlg->result() == 1 ) { | 1486 | if( fileDlg->result() == 1 ) { |
1487 | newServerName = fileDlg->LineEdit1->text(); | 1487 | newServerName = fileDlg->LineEdit1->text(); |
1488 | for(int i=1;i<serverListView->count();i++) { | 1488 | for(int i=1;i<serverListView->count();i++) { |
1489 | cfg.setGroup( QString::number(i)); | 1489 | cfg.setGroup( QString::number(i)); |
1490 | if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) { | 1490 | if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) { |
1491 | QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken")); | 1491 | QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken")); |
1492 | return; | 1492 | return; |
1493 | } | 1493 | } |
1494 | } | 1494 | } |
1495 | currentServerConfig =-1; | 1495 | currentServerConfig =-1; |
1496 | writeConfig(); | 1496 | writeConfig(); |
1497 | serverListView->insertItem( newServerName ); | 1497 | serverListView->insertItem( newServerName ); |
1498 | serverListView->setCurrentItem( serverListView->count()); | 1498 | serverListView->setCurrentItem( serverListView->count()); |
1499 | } | 1499 | } |
1500 | } | 1500 | } |
1501 | 1501 | ||
1502 | void OpieFtp::serverListClicked( const QString &item) { | 1502 | void OpieFtp::serverListClicked( const QString &item) { |
1503 | if(item.isEmpty()) return; | 1503 | if(item.isEmpty()) return; |
1504 | Config cfg("opieftp"); | 1504 | Config cfg("opieftp"); |
1505 | qDebug("highltined "+item); | 1505 | qDebug("highltined "+item); |
1506 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1506 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1507 | for (int i = 1; i <= numberOfEntries; i++) { | 1507 | for (int i = 1; i <= numberOfEntries; i++) { |
1508 | cfg.setGroup(QString::number(i)); | 1508 | cfg.setGroup(QString::number(i)); |
1509 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) | 1509 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) |
1510 | serverComboSelected(i-1); | 1510 | serverComboSelected(i-1); |
1511 | } | 1511 | } |