-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 @@ -1191,322 +1191,322 @@ void OpieFtp::switchToRemoteTab() TabWidget->setCurrentPage(1); } void OpieFtp::switchToConfigTab() { TabWidget->setCurrentPage(2); } void OpieFtp::readConfig() { fillCombos(); Config cfg("opieftp"); cfg.setGroup("Server"); currentServerConfig = cfg.readNumEntry("currentServer", -1); // qDebug("Reading %d", currentServerConfig); serverComboSelected( currentServerConfig-1); } void OpieFtp::writeConfig() { qDebug("write config"); Config cfg("opieftp"); cfg.setGroup("Server"); QString username, remoteServerStr, remotePathStr, password, port, temp; int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); if( currentServerConfig == -1) { for (int i = 1; i <= numberOfEntries; i++) { temp.setNum(i); cfg.setGroup("Server"); QString tempStr = cfg.readEntry( temp,""); } temp.setNum( numberOfEntries + 1); cfg.setGroup("Server"); remoteServerStr = cfg.readEntry( temp,""); int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); temp.setNum(numberOfEntries+1); cfg.setGroup("Server"); cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); cfg.writeEntry("currentServer", numberOfEntries+1); currentServerConfig = numberOfEntries+1; qDebug("setting currentserverconfig to %d", currentServerConfig); cfg.setGroup(temp); if(!newServerName.isEmpty()) cfg.writeEntry("ServerName", newServerName); cfg.writeEntry("RemotePath", remotePath->text()); cfg.writeEntry("Username", UsernameComboBox->currentText()); cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); cfg.setGroup("Server"); cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); } } void OpieFtp::clearCombos() { qDebug("clearing"); ServerComboBox->clear(); UsernameComboBox->clear(); PasswordEdit->clear(); serverListView->clear(); } void OpieFtp::fillCombos() { clearCombos(); Config cfg("opieftp"); cfg.setGroup("Server"); QString username, remoteServerStr, remotePathStr, password, port, temp; int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); for (int i = 1; i <= numberOfEntries; i++) { temp.setNum(i); qDebug(temp); cfg.setGroup("Server"); remoteServerStr = cfg.readEntry( temp,""); qDebug( remoteServerStr); int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); port = remoteServerStr.right( divider - 1); bool ok; PortSpinBox->setValue( port.toInt(&ok,10)); remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); qDebug( "remote server string "+remoteServerStr); ServerComboBox->insertItem( remoteServerStr ); cfg.setGroup(temp); username = cfg.readEntry(temp); UsernameComboBox->insertItem(username); password = cfg.readEntryCrypt(username,""); PasswordEdit->setText(password); serverListView->insertItem( cfg.readEntry("ServerName")); } } void OpieFtp::serverComboSelected(int index) { currentServerConfig = index+1; qDebug("server combo selected %d", index+1); QString username, remoteServerStr, remotePathStr, password, port, temp; // remoteServerStr = ServerComboBox->text(index); Config cfg("opieftp"); cfg.setGroup("Server"); // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); temp.setNum(index+1); remoteServerStr = cfg.readEntry( temp,""); qDebug("Group" +temp); cfg.setGroup(temp); // qDebug(temp); int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); port = remoteServerStr.right( divider - 1); bool ok; int portInt = port.toInt(&ok,10); if( portInt == 0) portInt = 21; ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); PortSpinBox->setValue( portInt); remotePath->setText(cfg.readEntry("RemotePath", "/")); username = cfg.readEntry("Username", "anonymous"); UsernameComboBox->lineEdit()->setText(username); qDebug(username); // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); // UsernameComboBox // PasswordEdit cfg.setGroup("Server"); temp.sprintf("%d",currentServerConfig); cfg.writeEntry("currentServer", temp); fuckeduphack = TRUE; serverListView->setCurrentItem( index); fuckeduphack=FALSE; qDebug("server list set selected %d",index); update(); } void OpieFtp::deleteServer() { QString username, remoteServerStr, remotePathStr, password, port, temp, servername; remoteServerStr = ServerComboBox->currentText( ); username = UsernameComboBox->currentText(); servername=serverListView->currentText(); Config cfg("opieftp"); cfg.setGroup("Server"); QString tempname; int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); for (int i = 1; i <= numberOfEntries; i++) { temp.setNum(i); // cfg.setGroup("Server"); cfg.setGroup(QString::number(i)); tempname=cfg.readEntry( "ServerName",""); if( tempname.find( servername,0,TRUE) != -1 ) { // servername.find( cfg.readEntry("ServerName")) != -1 && // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && // username.find( cfg.readEntry("Username")) != -1) { serverListView->removeItem(i); qDebug("OK DELETE "+tempname); cfg.removeEntry(QString::number(i)); - for ( i; i <= numberOfEntries; i++) { + for ( ; i <= numberOfEntries; i++) { cfg.setGroup("Server"); cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); cfg.setGroup(QString::number(i+1)); //get next server config servername=cfg.readEntry("ServerName"); remoteServerStr=cfg.readEntry("RemotePath"); username=cfg.readEntry("Username"); password=cfg.readEntryCrypt( username); cfg.setGroup(QString::number(i)); cfg.writeEntry("RemotePath", remoteServerStr); cfg.writeEntry("ServerName", servername); cfg.writeEntry("Username", username); cfg.writeEntryCrypt( username, password); } cfg.setGroup("Server"); cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 )); } } cfg.setGroup(QString::number(numberOfEntries)); cfg.removeEntry("Server"); cfg.removeEntry("RemotePath"); cfg.removeEntry("ServerName"); username=cfg.readEntry("Username"); cfg.removeEntry("Username"); cfg.removeEntry(username); currentServerConfig=currentServerConfig-1; fillCombos(); update(); } void OpieFtp::upDir() { if (TabWidget->currentPageIndex() == 0) { QString current = currentDir.canonicalPath(); QDir dir(current); dir.cdUp(); current = dir.canonicalPath(); chdir( current.latin1() ); currentDir.cd( current, TRUE); populateLocalView(); update(); } else { if( FtpCDUp( conn) == 0) { QString msg; msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); // qDebug(msg); } char path[256]; if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string QString msg; msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); // qDebug(msg); } currentRemoteDir=path; remoteDirList( (const QString &)currentRemoteDir); //this also calls populate if(currentRemoteDir.right(1) !="/") currentRemoteDir +="/"; currentPathCombo->lineEdit()->setText( currentRemoteDir); fillRemoteCombo( (const QString &)currentRemoteDir); } } void OpieFtp::docButtonPushed() { QString current = QPEApplication::documentDir(); chdir( current.latin1() ); currentDir.cd( current, TRUE); populateLocalView(); update(); } void OpieFtp::homeButtonPushed() { QString current = QDir::homeDirPath(); chdir( current.latin1() ); currentDir.cd( current, TRUE); populateLocalView(); update(); } void OpieFtp::doAbout() { QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" "L.J.Potter<llornkcor@handhelds.org>\n" "and uses ftplib copyright 1996-2000\n" "by Thomas Pfau, pfau@cnj.digex.net\n\n" "and is licensed by the GPL"); } void OpieFtp::NewServer() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0); fileDlg->exec(); Config cfg("opieftp"); if( fileDlg->result() == 1 ) { newServerName = fileDlg->LineEdit1->text(); for(int i=1;i<serverListView->count();i++) { cfg.setGroup( QString::number(i)); if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) { QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken")); return; } } currentServerConfig =-1; writeConfig(); serverListView->insertItem( newServerName ); serverListView->setCurrentItem( serverListView->count()); } } void OpieFtp::serverListClicked( const QString &item) { if(item.isEmpty()) return; Config cfg("opieftp"); qDebug("highltined "+item); int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); for (int i = 1; i <= numberOfEntries; i++) { cfg.setGroup(QString::number(i)); if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) serverComboSelected(i-1); } } |