summaryrefslogtreecommitdiff
path: root/noncore/net/opieftp/opieftp.cpp
authorllornkcor <llornkcor>2002-04-05 01:34:24 (UTC)
committer llornkcor <llornkcor>2002-04-05 01:34:24 (UTC)
commitdd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670 (patch) (unidiff)
treee8ebf3f926e3ac7e4d612964a05bce834fe6fc2e /noncore/net/opieftp/opieftp.cpp
parent8674b15e0768d5108d9a225ff2631538283e1019 (diff)
downloadopie-dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670.zip
opie-dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670.tar.gz
opie-dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670.tar.bz2
fixed bug where same server was being saved multiple times
Diffstat (limited to 'noncore/net/opieftp/opieftp.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index b451925..919649e 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -107,25 +107,25 @@ OpieFtp::OpieFtp( )
107 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 107 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
108 remoteMenu->insertSeparator(); 108 remoteMenu->insertSeparator();
109 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 109 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
110 110
111 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 111 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
112 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 112 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
113 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 113 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
114 tabMenu->setCheckable(TRUE); 114 tabMenu->setCheckable(TRUE);
115 115
116 TabWidget = new QTabWidget( this, "TabWidget" ); 116 TabWidget = new QTabWidget( this, "TabWidget" );
117 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); 117 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 );
118 118
119 TabWidget->setTabShape(QTabWidget::Triangular); 119// TabWidget->setTabShape(QTabWidget::Triangular);
120 120
121 tab = new QWidget( TabWidget, "tab" ); 121 tab = new QWidget( TabWidget, "tab" );
122 tabLayout = new QGridLayout( tab ); 122 tabLayout = new QGridLayout( tab );
123 tabLayout->setSpacing( 2); 123 tabLayout->setSpacing( 2);
124 tabLayout->setMargin( 2); 124 tabLayout->setMargin( 2);
125 125
126 Local_View = new QListView( tab, "Local_View" ); 126 Local_View = new QListView( tab, "Local_View" );
127// Local_View->setResizePolicy( QListView::AutoOneFit ); 127// Local_View->setResizePolicy( QListView::AutoOneFit );
128 Local_View->addColumn( tr("File"),150); 128 Local_View->addColumn( tr("File"),150);
129 Local_View->addColumn( tr("Size"),-1); 129 Local_View->addColumn( tr("Size"),-1);
130 Local_View->setColumnAlignment(1,QListView::AlignRight); 130 Local_View->setColumnAlignment(1,QListView::AlignRight);
131 Local_View->addColumn( tr("Date"),-1); 131 Local_View->addColumn( tr("Date"),-1);
@@ -259,24 +259,25 @@ OpieFtp::OpieFtp( )
259 this,SLOT(currentPathComboChanged())); 259 this,SLOT(currentPathComboChanged()));
260 260
261 ProgressBar = new QProgressBar( this, "ProgressBar" ); 261 ProgressBar = new QProgressBar( this, "ProgressBar" );
262 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 262 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
263 263
264// fillCombos(); 264// fillCombos();
265 265
266 filterStr="*"; 266 filterStr="*";
267 b=FALSE; 267 b=FALSE;
268 populateLocalView(); 268 populateLocalView();
269 readConfig(); 269 readConfig();
270 ServerComboBox->setCurrentItem(currentServerConfig); 270 ServerComboBox->setCurrentItem(currentServerConfig);
271
271 TabWidget->setCurrentPage(2); 272 TabWidget->setCurrentPage(2);
272} 273}
273 274
274OpieFtp::~OpieFtp() 275OpieFtp::~OpieFtp()
275{ 276{
276} 277}
277 278
278void OpieFtp::cleanUp() 279void OpieFtp::cleanUp()
279{ 280{
280 if(conn) 281 if(conn)
281 FtpQuit(conn); 282 FtpQuit(conn);
282 QString sfile=QDir::homeDirPath(); 283 QString sfile=QDir::homeDirPath();
@@ -314,27 +315,27 @@ void OpieFtp::tabChanged(QWidget *w)
314void OpieFtp::newConnection() 315void OpieFtp::newConnection()
315{ 316{
316 UsernameComboBox->lineEdit()->setText(""); 317 UsernameComboBox->lineEdit()->setText("");
317 PasswordEdit->setText( "" ); 318 PasswordEdit->setText( "" );
318 ServerComboBox->lineEdit()->setText( ""); 319 ServerComboBox->lineEdit()->setText( "");
319 remotePath->setText( currentRemoteDir = "/"); 320 remotePath->setText( currentRemoteDir = "/");
320 PortSpinBox->setValue( 21); 321 PortSpinBox->setValue( 21);
321 TabWidget->setCurrentPage(2); 322 TabWidget->setCurrentPage(2);
322} 323}
323 324
324void OpieFtp::serverComboEdited(const QString & edit) 325void OpieFtp::serverComboEdited(const QString & edit)
325{ 326{
326 if( !edit.isEmpty() ) { 327 if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) {
328 qDebug("ServerComboEdited");
327 currentServerConfig = -1; 329 currentServerConfig = -1;
328// qDebug("comboedited");
329 } 330 }
330} 331}
331 332
332void OpieFtp::connectorBtnToggled(bool On) 333void OpieFtp::connectorBtnToggled(bool On)
333{ 334{
334 if(On) { 335 if(On) {
335 connector(); 336 connector();
336 } else { 337 } else {
337 disConnector(); 338 disConnector();
338 } 339 }
339 340
340} 341}
@@ -514,25 +515,25 @@ bool OpieFtp::remoteDirList(const QString &dir)
514 QCopEnvelope ( "QPE/System", "notBusy()" ); 515 QCopEnvelope ( "QPE/System", "notBusy()" );
515 return true; 516 return true;
516} 517}
517 518
518bool OpieFtp::remoteChDir(const QString &dir) 519bool OpieFtp::remoteChDir(const QString &dir)
519{ 520{
520 QCopEnvelope ( "QPE/System", "busy()" ); 521 QCopEnvelope ( "QPE/System", "busy()" );
521 if (!FtpChdir( dir.latin1(), conn )) { 522 if (!FtpChdir( dir.latin1(), conn )) {
522 QString msg; 523 QString msg;
523 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 524 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
524 msg.replace(QRegExp(":"),"\n"); 525 msg.replace(QRegExp(":"),"\n");
525 QMessageBox::message(tr("Note"),msg); 526 QMessageBox::message(tr("Note"),msg);
526 qDebug(msg); 527// qDebug(msg);
527 QCopEnvelope ( "QPE/System", "notBusy()" ); 528 QCopEnvelope ( "QPE/System", "notBusy()" );
528 return FALSE; 529 return FALSE;
529 } 530 }
530 QCopEnvelope ( "QPE/System", "notBusy()" ); 531 QCopEnvelope ( "QPE/System", "notBusy()" );
531 return TRUE; 532 return TRUE;
532} 533}
533 534
534void OpieFtp::populateLocalView() 535void OpieFtp::populateLocalView()
535{ 536{
536 Local_View->clear(); 537 Local_View->clear();
537 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 538 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
538 currentDir.setMatchAllDirs(TRUE); 539 currentDir.setMatchAllDirs(TRUE);
@@ -658,33 +659,33 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
658{ 659{
659 if( selectedItem) { 660 if( selectedItem) {
660// QCopEnvelope ( "QPE/System", "busy()" ); 661// QCopEnvelope ( "QPE/System", "busy()" );
661 QString oldRemoteCurrentDir = currentRemoteDir; 662 QString oldRemoteCurrentDir = currentRemoteDir;
662 QString strItem=selectedItem->text(0); 663 QString strItem=selectedItem->text(0);
663 strItem=strItem.simplifyWhiteSpace(); 664 strItem=strItem.simplifyWhiteSpace();
664 if(strItem == "../") { // the user wants to go ^ 665 if(strItem == "../") { // the user wants to go ^
665 if( FtpCDUp( conn) == 0) { 666 if( FtpCDUp( conn) == 0) {
666 QString msg; 667 QString msg;
667 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 668 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
668 msg.replace(QRegExp(":"),"\n"); 669 msg.replace(QRegExp(":"),"\n");
669 QMessageBox::message(tr("Note"),msg); 670 QMessageBox::message(tr("Note"),msg);
670 qDebug(msg); 671// qDebug(msg);
671 } 672 }
672 char path[256]; 673 char path[256];
673 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 674 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
674 QString msg; 675 QString msg;
675 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 676 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
676 msg.replace(QRegExp(":"),"\n"); 677 msg.replace(QRegExp(":"),"\n");
677 QMessageBox::message(tr("Note"),msg); 678 QMessageBox::message(tr("Note"),msg);
678 qDebug(msg); 679// qDebug(msg);
679 } 680 }
680 currentRemoteDir=path; 681 currentRemoteDir=path;
681 } else { 682 } else {
682 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 683 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
683 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 684 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
684 strItem = strItem.stripWhiteSpace(); 685 strItem = strItem.stripWhiteSpace();
685 currentRemoteDir = strItem; 686 currentRemoteDir = strItem;
686 if( !remoteChDir( (const QString &)strItem)) { 687 if( !remoteChDir( (const QString &)strItem)) {
687 currentRemoteDir = oldRemoteCurrentDir; 688 currentRemoteDir = oldRemoteCurrentDir;
688 strItem=""; 689 strItem="";
689// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 690// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
690 } 691 }
@@ -1056,40 +1057,40 @@ void OpieFtp::switchToRemoteTab()
1056 1057
1057void OpieFtp::switchToConfigTab() 1058void OpieFtp::switchToConfigTab()
1058{ 1059{
1059 TabWidget->setCurrentPage(2); 1060 TabWidget->setCurrentPage(2);
1060} 1061}
1061 1062
1062void OpieFtp::readConfig() 1063void OpieFtp::readConfig()
1063{ 1064{
1064 fillCombos(); 1065 fillCombos();
1065 Config cfg("opieftp"); 1066 Config cfg("opieftp");
1066 cfg.setGroup("Server"); 1067 cfg.setGroup("Server");
1067 currentServerConfig = cfg.readNumEntry("currentServer", -1); 1068 currentServerConfig = cfg.readNumEntry("currentServer", -1);
1069// qDebug("Reading %d", currentServerConfig);
1068 serverComboSelected( currentServerConfig); 1070 serverComboSelected( currentServerConfig);
1069} 1071}
1070 1072
1071void OpieFtp::writeConfig() 1073void OpieFtp::writeConfig()
1072{ 1074{
1073 Config cfg("opieftp"); 1075 Config cfg("opieftp");
1074 cfg.setGroup("Server"); 1076 cfg.setGroup("Server");
1075 QString username, remoteServerStr, remotePathStr, password, port, temp; 1077 QString username, remoteServerStr, remotePathStr, password, port, temp;
1076 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1078 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1077 if( currentServerConfig == -1) { 1079 if( currentServerConfig == -1) {
1078 for (int i = 1; i <= numberOfEntries; i++) { 1080 for (int i = 1; i <= numberOfEntries; i++) {
1079 temp.setNum(i); 1081 temp.setNum(i);
1080 cfg.setGroup("Server"); 1082 cfg.setGroup("Server");
1081 QString tempStr = cfg.readEntry( temp,""); 1083 QString tempStr = cfg.readEntry( temp,"");
1082 } 1084 }
1083
1084 temp.setNum( numberOfEntries + 1); 1085 temp.setNum( numberOfEntries + 1);
1085 cfg.setGroup("Server"); 1086 cfg.setGroup("Server");
1086 remoteServerStr = cfg.readEntry( temp,""); 1087 remoteServerStr = cfg.readEntry( temp,"");
1087 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1088 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1088 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1089 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1089 1090
1090 temp.setNum(numberOfEntries+1); 1091 temp.setNum(numberOfEntries+1);
1091 cfg.setGroup("Server"); 1092 cfg.setGroup("Server");
1092 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); 1093 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
1093 cfg.setGroup(temp); 1094 cfg.setGroup(temp);
1094 cfg.writeEntry("RemotePath", remotePath->text()); 1095 cfg.writeEntry("RemotePath", remotePath->text());
1095 cfg.writeEntry("Username", UsernameComboBox->currentText()); 1096 cfg.writeEntry("Username", UsernameComboBox->currentText());