-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index e2a6cad..e97a9bf 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -122,64 +122,66 @@ OpieFtp::OpieFtp( ) | |||
122 | tabLayout->setMargin( 2); | 122 | tabLayout->setMargin( 2); |
123 | 123 | ||
124 | Local_View = new QListView( tab, "Local_View" ); | 124 | Local_View = new QListView( tab, "Local_View" ); |
125 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 125 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
126 | Local_View->addColumn( tr("File"),120); | 126 | Local_View->addColumn( tr("File"),120); |
127 | Local_View->addColumn( tr("Size"),-1); | 127 | Local_View->addColumn( tr("Size"),-1); |
128 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 128 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
129 | Local_View->addColumn( tr("Date"),-1); | 129 | Local_View->addColumn( tr("Date"),-1); |
130 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 130 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
131 | Local_View->setAllColumnsShowFocus(TRUE); | 131 | Local_View->setAllColumnsShowFocus(TRUE); |
132 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 132 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
133 | 133 | ||
134 | tabLayout->addWidget( Local_View, 0, 0 ); | 134 | tabLayout->addWidget( Local_View, 0, 0 ); |
135 | 135 | ||
136 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 136 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
137 | this,SLOT( localListClicked(QListViewItem *)) ); | 137 | this,SLOT( localListClicked(QListViewItem *)) ); |
138 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 138 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
139 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 139 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
140 | 140 | ||
141 | TabWidget->insertTab( tab, tr( "Local" ) ); | 141 | TabWidget->insertTab( tab, tr( "Local" ) ); |
142 | 142 | ||
143 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 143 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
144 | tabLayout_2 = new QGridLayout( tab_2 ); | 144 | tabLayout_2 = new QGridLayout( tab_2 ); |
145 | tabLayout_2->setSpacing( 2); | 145 | tabLayout_2->setSpacing( 2); |
146 | tabLayout_2->setMargin( 2); | 146 | tabLayout_2->setMargin( 2); |
147 | 147 | ||
148 | Remote_View = new QListView( tab_2, "Remote_View" ); | 148 | Remote_View = new QListView( tab_2, "Remote_View" ); |
149 | Remote_View->addColumn( tr("File"),120); | 149 | Remote_View->addColumn( tr("File"),120); |
150 | Remote_View->addColumn( tr("Size"),-1); | 150 | Remote_View->addColumn( tr("Size"),-1); |
151 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 151 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
152 | Remote_View->addColumn( tr("Date"),-1); | 152 | Remote_View->addColumn( tr("Date"),-1); |
153 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 153 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
154 | Remote_View->addColumn( tr("Dir"),-1); | ||
155 | Remote_View->setColumnAlignment(4,QListView::AlignRight); | ||
154 | Remote_View->setAllColumnsShowFocus(TRUE); | 156 | Remote_View->setAllColumnsShowFocus(TRUE); |
155 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 157 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
156 | 158 | ||
157 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 159 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
158 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 160 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
159 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 161 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
160 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 162 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
161 | 163 | ||
162 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 164 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
163 | 165 | ||
164 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); | 166 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); |
165 | 167 | ||
166 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 168 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
167 | tabLayout_3 = new QGridLayout( tab_3 ); | 169 | tabLayout_3 = new QGridLayout( tab_3 ); |
168 | tabLayout_3->setSpacing( 2); | 170 | tabLayout_3->setSpacing( 2); |
169 | tabLayout_3->setMargin( 2); | 171 | tabLayout_3->setMargin( 2); |
170 | 172 | ||
171 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); | 173 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); |
172 | TextLabel1->setText( tr( "Username" ) ); | 174 | TextLabel1->setText( tr( "Username" ) ); |
173 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); | 175 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); |
174 | 176 | ||
175 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); | 177 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); |
176 | UsernameComboBox->setEditable(TRUE); | 178 | UsernameComboBox->setEditable(TRUE); |
177 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); | 179 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); |
178 | 180 | ||
179 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 181 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
180 | TextLabel2->setText( tr( "Password" ) ); | 182 | TextLabel2->setText( tr( "Password" ) ); |
181 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); | 183 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); |
182 | 184 | ||
183 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 185 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
184 | PasswordEdit->setEchoMode(QLineEdit::Password); | 186 | PasswordEdit->setEchoMode(QLineEdit::Password); |
185 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); | 187 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); |
@@ -214,81 +216,82 @@ OpieFtp::OpieFtp( ) | |||
214 | QPushButton *deleteServerBtn; | 216 | QPushButton *deleteServerBtn; |
215 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); | 217 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); |
216 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); | 218 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); |
217 | 219 | ||
218 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | 220 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); |
219 | 221 | ||
220 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); | 222 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); |
221 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); | 223 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); |
222 | connectServerBtn->setToggleButton(TRUE); | 224 | connectServerBtn->setToggleButton(TRUE); |
223 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); | 225 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); |
224 | 226 | ||
225 | 227 | ||
226 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 228 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
227 | tabLayout_3->addItem( spacer, 5, 0 ); | 229 | tabLayout_3->addItem( spacer, 5, 0 ); |
228 | 230 | ||
229 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 231 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
230 | 232 | ||
231 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 233 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
232 | this,SLOT(tabChanged(QWidget*))); | 234 | this,SLOT(tabChanged(QWidget*))); |
233 | 235 | ||
234 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 236 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
235 | currentDir.setPath( QDir::currentDirPath()); | 237 | currentDir.setPath( QDir::currentDirPath()); |
236 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 238 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
237 | currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); | 239 | currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); |
238 | layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); | 240 | layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); |
239 | 241 | ||
240 | currentPathEdit->setText( currentDir.canonicalPath()); | 242 | currentPathEdit->setText( currentDir.canonicalPath()); |
241 | connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); | 243 | connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); |
242 | 244 | ||
243 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 245 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
244 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); | 246 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); |
245 | 247 | ||
246 | serverComboSelected(0); | 248 | // fillCombos(); |
247 | fillCombos(); | ||
248 | 249 | ||
249 | #ifdef DEVELOPERS_VERSION | 250 | #ifdef DEVELOPERS_VERSION |
250 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 251 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
251 | UsernameComboBox->lineEdit()->setText("root"); | 252 | UsernameComboBox->lineEdit()->setText("root"); |
252 | PortSpinBox->setValue( 4242); | 253 | PortSpinBox->setValue( 4242); |
253 | remotePath->setText( currentRemoteDir = "/"); | 254 | remotePath->setText( currentRemoteDir = "/"); |
254 | // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); | 255 | // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); |
255 | // UsernameComboBox->lineEdit()->setText("llornkcor"); | 256 | // UsernameComboBox->lineEdit()->setText("llornkcor"); |
256 | // PortSpinBox->setValue( 21); | 257 | // PortSpinBox->setValue( 21); |
257 | // remotePath->setText( currentRemoteDir = "/home/llornkcor"); | 258 | // remotePath->setText( currentRemoteDir = "/home/llornkcor"); |
258 | PasswordEdit->setText( tr( "" ) ); | 259 | PasswordEdit->setText( tr( "" ) ); |
259 | #endif | 260 | #endif |
260 | filterStr="*"; | 261 | filterStr="*"; |
261 | b=FALSE; | 262 | b=FALSE; |
262 | populateLocalView(); | 263 | populateLocalView(); |
264 | readConfig(); | ||
265 | ServerComboBox->setCurrentItem(currentServerConfig); | ||
263 | TabWidget->setCurrentPage(2); | 266 | TabWidget->setCurrentPage(2); |
264 | } | 267 | } |
265 | 268 | ||
266 | OpieFtp::~OpieFtp() | 269 | OpieFtp::~OpieFtp() |
267 | { | 270 | { |
268 | } | 271 | } |
269 | 272 | ||
270 | void OpieFtp::cleanUp() | 273 | void OpieFtp::cleanUp() |
271 | { | 274 | { |
272 | if(conn) | 275 | if(conn) |
273 | FtpQuit(conn); | 276 | FtpQuit(conn); |
274 | QString sfile=QDir::homeDirPath(); | 277 | QString sfile=QDir::homeDirPath(); |
275 | if(sfile.right(1) != "/") | 278 | if(sfile.right(1) != "/") |
276 | sfile+="/._temp"; | 279 | sfile+="/._temp"; |
277 | else | 280 | else |
278 | sfile+="._temp"; | 281 | sfile+="._temp"; |
279 | QFile file( sfile); | 282 | QFile file( sfile); |
280 | if(file.exists()) | 283 | if(file.exists()) |
281 | file.remove(); | 284 | file.remove(); |
282 | } | 285 | } |
283 | 286 | ||
284 | void OpieFtp::tabChanged(QWidget *w) | 287 | void OpieFtp::tabChanged(QWidget *w) |
285 | { | 288 | { |
286 | if (TabWidget->currentPageIndex() == 0) { | 289 | if (TabWidget->currentPageIndex() == 0) { |
287 | currentPathEdit->setText( currentDir.canonicalPath()); | 290 | currentPathEdit->setText( currentDir.canonicalPath()); |
288 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); | 291 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); |
289 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 292 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
290 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 293 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
291 | } | 294 | } |
292 | if (TabWidget->currentPageIndex() == 1) { | 295 | if (TabWidget->currentPageIndex() == 1) { |
293 | currentPathEdit->setText( currentRemoteDir ); | 296 | currentPathEdit->setText( currentRemoteDir ); |
294 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); | 297 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); |
@@ -552,87 +555,88 @@ void OpieFtp::populateLocalView() | |||
552 | } | 555 | } |
553 | Local_View->setSorting( 3,FALSE); | 556 | Local_View->setSorting( 3,FALSE); |
554 | currentPathEdit->setText( currentDir.canonicalPath() ); | 557 | currentPathEdit->setText( currentDir.canonicalPath() ); |
555 | } | 558 | } |
556 | 559 | ||
557 | bool OpieFtp::populateRemoteView( ) | 560 | bool OpieFtp::populateRemoteView( ) |
558 | { | 561 | { |
559 | // qDebug("populate remoteview"); | 562 | // qDebug("populate remoteview"); |
560 | QString sfile=QDir::homeDirPath(); | 563 | QString sfile=QDir::homeDirPath(); |
561 | if(sfile.right(1) != "/") | 564 | if(sfile.right(1) != "/") |
562 | sfile+="/._temp"; | 565 | sfile+="/._temp"; |
563 | else | 566 | else |
564 | sfile+="._temp"; | 567 | sfile+="._temp"; |
565 | QFile file( sfile); | 568 | QFile file( sfile); |
566 | Remote_View->clear(); | 569 | Remote_View->clear(); |
567 | QString s, File_Name; | 570 | QString s, File_Name; |
568 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 571 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
569 | QString fileL, fileS, fileDate; | 572 | QString fileL, fileS, fileDate; |
570 | if ( file.open(IO_ReadOnly)) { | 573 | if ( file.open(IO_ReadOnly)) { |
571 | QTextStream t( &file ); // use a text stream | 574 | QTextStream t( &file ); // use a text stream |
572 | while ( !t.eof()) { | 575 | while ( !t.eof()) { |
573 | s = t.readLine(); | 576 | s = t.readLine(); |
574 | fileL = s.right(s.length()-55); | 577 | fileL = s.right(s.length()-55); |
575 | fileL = fileL.stripWhiteSpace(); | 578 | fileL = fileL.stripWhiteSpace(); |
576 | if(s.left(1) == "d") | 579 | if(s.left(1) == "d") |
577 | fileL = fileL+"/"; | 580 | fileL = fileL+"/"; |
578 | // fileL = "/"+fileL+"/"; | 581 | // fileL = "/"+fileL+"/"; |
579 | fileS = s.mid( 30, 42-30); | 582 | fileS = s.mid( 30, 42-30); |
580 | fileS = fileS.stripWhiteSpace(); | 583 | fileS = fileS.stripWhiteSpace(); |
581 | fileDate = s.mid( 42, 55-42); | 584 | fileDate = s.mid( 42, 55-42); |
582 | fileDate = fileDate.stripWhiteSpace(); | 585 | fileDate = fileDate.stripWhiteSpace(); |
583 | if(fileL.find("total",0,TRUE) == -1) { | 586 | if(fileL.find("total",0,TRUE) == -1) { |
584 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate); | ||
585 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { | 587 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
588 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); | ||
586 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 589 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
587 | if(itemDir) | 590 | // if(itemDir) |
588 | item->moveItem(itemDir); | 591 | item->moveItem(itemDir); |
589 | itemDir=item; | 592 | itemDir=item; |
590 | } else { | 593 | } else { |
594 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); | ||
591 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 595 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
592 | if(itemFile) | 596 | // if(itemFile) |
597 | item->moveItem(itemDir); | ||
593 | item->moveItem(itemFile); | 598 | item->moveItem(itemFile); |
594 | itemFile=item; | 599 | itemFile=item; |
595 | } | 600 | } |
596 | } | 601 | } |
597 | } | 602 | } |
598 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 603 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
599 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 604 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
600 | file.close(); | 605 | file.close(); |
601 | if( file.exists()) | 606 | if( file.exists()) |
602 | file. remove(); | 607 | file. remove(); |
603 | } else | 608 | } else |
604 | qDebug("temp file not opened successfullly "+sfile); | 609 | qDebug("temp file not opened successfullly "+sfile); |
605 | Remote_View->setSorting( 4,TRUE); | 610 | Remote_View->setSorting( 4,TRUE); |
606 | |||
607 | return true; | 611 | return true; |
608 | } | 612 | } |
609 | 613 | ||
610 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 614 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
611 | { | 615 | { |
612 | QCopEnvelope ( "QPE/System", "busy()" ); | 616 | QCopEnvelope ( "QPE/System", "busy()" ); |
613 | QString oldRemoteCurrentDir = currentRemoteDir; | 617 | QString oldRemoteCurrentDir = currentRemoteDir; |
614 | QString strItem=selectedItem->text(0); | 618 | QString strItem=selectedItem->text(0); |
615 | strItem=strItem.simplifyWhiteSpace(); | 619 | strItem=strItem.simplifyWhiteSpace(); |
616 | if(strItem == "../") { // the user wants to go ^ | 620 | if(strItem == "../") { // the user wants to go ^ |
617 | if( FtpCDUp( conn) == 0) { | 621 | if( FtpCDUp( conn) == 0) { |
618 | QString msg; | 622 | QString msg; |
619 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 623 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
620 | msg.replace(QRegExp(":"),"\n"); | 624 | msg.replace(QRegExp(":"),"\n"); |
621 | QMessageBox::message(tr("Note"),msg); | 625 | QMessageBox::message(tr("Note"),msg); |
622 | qDebug(msg); | 626 | qDebug(msg); |
623 | } | 627 | } |
624 | char path[256]; | 628 | char path[256]; |
625 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 629 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
626 | QString msg; | 630 | QString msg; |
627 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 631 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
628 | msg.replace(QRegExp(":"),"\n"); | 632 | msg.replace(QRegExp(":"),"\n"); |
629 | QMessageBox::message(tr("Note"),msg); | 633 | QMessageBox::message(tr("Note"),msg); |
630 | qDebug(msg); | 634 | qDebug(msg); |
631 | } | 635 | } |
632 | currentRemoteDir=path; | 636 | currentRemoteDir=path; |
633 | } else { | 637 | } else { |
634 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 638 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
635 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 639 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
636 | strItem = strItem.stripWhiteSpace(); | 640 | strItem = strItem.stripWhiteSpace(); |
637 | currentRemoteDir = strItem; | 641 | currentRemoteDir = strItem; |
638 | if( !remoteChDir( (const QString &)strItem)) { | 642 | if( !remoteChDir( (const QString &)strItem)) { |
@@ -943,89 +947,69 @@ void OpieFtp::currentPathEditChanged() | |||
943 | if (TabWidget->currentPageIndex() == 1) { | 947 | if (TabWidget->currentPageIndex() == 1) { |
944 | currentRemoteDir = currentPathEdit->text(); | 948 | currentRemoteDir = currentPathEdit->text(); |
945 | if(currentRemoteDir.right(1) !="/") { | 949 | if(currentRemoteDir.right(1) !="/") { |
946 | currentRemoteDir = currentRemoteDir +"/"; | 950 | currentRemoteDir = currentRemoteDir +"/"; |
947 | currentPathEdit->setText( currentRemoteDir ); | 951 | currentPathEdit->setText( currentRemoteDir ); |
948 | } | 952 | } |
949 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 953 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
950 | currentRemoteDir = oldRemoteCurrentDir; | 954 | currentRemoteDir = oldRemoteCurrentDir; |
951 | currentPathEdit->setText( currentRemoteDir ); | 955 | currentPathEdit->setText( currentRemoteDir ); |
952 | } | 956 | } |
953 | 957 | ||
954 | remoteDirList( (const QString &)currentRemoteDir); | 958 | remoteDirList( (const QString &)currentRemoteDir); |
955 | } | 959 | } |
956 | } | 960 | } |
957 | 961 | ||
958 | void OpieFtp::switchToLocalTab() | 962 | void OpieFtp::switchToLocalTab() |
959 | { | 963 | { |
960 | TabWidget->setCurrentPage(0); | 964 | TabWidget->setCurrentPage(0); |
961 | } | 965 | } |
962 | 966 | ||
963 | void OpieFtp::switchToRemoteTab() | 967 | void OpieFtp::switchToRemoteTab() |
964 | { | 968 | { |
965 | TabWidget->setCurrentPage(1); | 969 | TabWidget->setCurrentPage(1); |
966 | } | 970 | } |
967 | 971 | ||
968 | void OpieFtp::switchToConfigTab() | 972 | void OpieFtp::switchToConfigTab() |
969 | { | 973 | { |
970 | TabWidget->setCurrentPage(2); | 974 | TabWidget->setCurrentPage(2); |
971 | } | 975 | } |
972 | 976 | ||
973 | void OpieFtp::readConfig() | 977 | void OpieFtp::readConfig() |
974 | { | 978 | { |
975 | 979 | fillCombos(); | |
976 | Config cfg("opieftp"); | 980 | Config cfg("opieftp"); |
977 | cfg.setGroup("Server"); | 981 | cfg.setGroup("Server"); |
978 | QString username, remoteServer, remotePathStr, password, port, temp; | 982 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
979 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 983 | serverComboSelected( currentServerConfig); |
980 | for (int i = 0; i <= numberOfEntries; i++) { | ||
981 | temp.setNum(i+1); | ||
982 | cfg.setGroup("Server"); | ||
983 | remoteServer = cfg.readEntry( temp,""); | ||
984 | ServerComboBox->insertItem( remoteServer ); | ||
985 | cfg.setGroup(temp); | ||
986 | |||
987 | remotePathStr = cfg.readEntry(remoteServer,""); | ||
988 | int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); | ||
989 | port = remoteServer.right( divider+1); | ||
990 | bool ok; | ||
991 | PortSpinBox->setValue( port.toInt(&ok,10)); | ||
992 | |||
993 | remoteServer = remoteServer.left(divider - 1); | ||
994 | remotePath->setText( remotePathStr); | ||
995 | username = cfg.readEntry(temp); | ||
996 | UsernameComboBox->insertItem(username); | ||
997 | password = cfg.readEntryCrypt(username,""); | ||
998 | PasswordEdit->setText(password); | ||
999 | } | ||
1000 | } | 984 | } |
1001 | 985 | ||
1002 | void OpieFtp::writeConfig() | 986 | void OpieFtp::writeConfig() |
1003 | { | 987 | { |
1004 | 988 | ||
1005 | Config cfg("opieftp"); | 989 | Config cfg("opieftp"); |
1006 | cfg.setGroup("Server"); | 990 | cfg.setGroup("Server"); |
1007 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 991 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1008 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 992 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1009 | if( currentServerConfig == -1) { | 993 | if( currentServerConfig == -1) { |
1010 | 994 | ||
1011 | temp.setNum( numberOfEntries + 1); | 995 | temp.setNum( numberOfEntries + 1); |
1012 | cfg.setGroup("Server"); | 996 | cfg.setGroup("Server"); |
1013 | remoteServerStr = cfg.readEntry( temp,""); | 997 | remoteServerStr = cfg.readEntry( temp,""); |
1014 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 998 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1015 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 999 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1016 | 1000 | ||
1017 | temp.setNum(numberOfEntries+1); | 1001 | temp.setNum(numberOfEntries+1); |
1018 | cfg.setGroup("Server"); | 1002 | cfg.setGroup("Server"); |
1019 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1003 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1020 | cfg.setGroup(temp); | 1004 | cfg.setGroup(temp); |
1021 | cfg.writeEntry("RemotePath", remotePath->text()); | 1005 | cfg.writeEntry("RemotePath", remotePath->text()); |
1022 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1006 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1023 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1007 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1024 | cfg.setGroup("Server"); | 1008 | cfg.setGroup("Server"); |
1025 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1009 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1026 | 1010 | ||
1027 | } | 1011 | } |
1028 | } | 1012 | } |
1029 | 1013 | ||
1030 | void OpieFtp::fillCombos() | 1014 | void OpieFtp::fillCombos() |
1031 | { | 1015 | { |
@@ -1059,58 +1043,62 @@ void OpieFtp::fillCombos() | |||
1059 | // password = cfg.readEntryCrypt(username,""); | 1043 | // password = cfg.readEntryCrypt(username,""); |
1060 | // PasswordEdit->setText(password); | 1044 | // PasswordEdit->setText(password); |
1061 | } | 1045 | } |
1062 | } | 1046 | } |
1063 | 1047 | ||
1064 | 1048 | ||
1065 | void OpieFtp::serverComboSelected(int index) | 1049 | void OpieFtp::serverComboSelected(int index) |
1066 | { | 1050 | { |
1067 | currentServerConfig = index; | 1051 | currentServerConfig = index; |
1068 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1052 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1069 | // remoteServerStr = ServerComboBox->text(index); | 1053 | // remoteServerStr = ServerComboBox->text(index); |
1070 | Config cfg("opieftp"); | 1054 | Config cfg("opieftp"); |
1071 | cfg.setGroup("Server"); | 1055 | cfg.setGroup("Server"); |
1072 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1056 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1073 | 1057 | ||
1074 | temp.setNum(index+1); | 1058 | temp.setNum(index+1); |
1075 | remoteServerStr = cfg.readEntry( temp,""); | 1059 | remoteServerStr = cfg.readEntry( temp,""); |
1076 | cfg.setGroup(temp); | 1060 | cfg.setGroup(temp); |
1077 | qDebug(temp); | 1061 | qDebug(temp); |
1078 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1062 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1079 | port = remoteServerStr.right( divider - 1); | 1063 | port = remoteServerStr.right( divider - 1); |
1080 | bool ok; | 1064 | bool ok; |
1081 | int portInt = port.toInt(&ok,10); | 1065 | int portInt = port.toInt(&ok,10); |
1082 | if( portInt == 0) portInt = 21; | 1066 | if( portInt == 0) portInt = 21; |
1083 | 1067 | ||
1084 | PortSpinBox->setValue( portInt); | 1068 | PortSpinBox->setValue( portInt); |
1085 | 1069 | ||
1086 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1070 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
1087 | 1071 | ||
1088 | username = cfg.readEntry("Username", "anonymous"); | 1072 | username = cfg.readEntry("Username", "anonymous"); |
1089 | UsernameComboBox->lineEdit()->setText(username); | 1073 | UsernameComboBox->lineEdit()->setText(username); |
1090 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); | 1074 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); |
1075 | |||
1076 | cfg.setGroup("Server"); | ||
1077 | temp.sprintf("%d",currentServerConfig); | ||
1078 | cfg.writeEntry("currentServer", temp); | ||
1091 | update(); | 1079 | update(); |
1092 | } | 1080 | } |
1093 | // UsernameComboBox->lineEdit()->setText("root"); | 1081 | // UsernameComboBox->lineEdit()->setText("root"); |
1094 | // PasswordEdit->setText( tr( "" ) ); | 1082 | // PasswordEdit->setText( tr( "" ) ); |
1095 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 1083 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
1096 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); | 1084 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); |
1097 | // PortSpinBox->setValue( 4242); | 1085 | // PortSpinBox->setValue( 4242); |
1098 | 1086 | ||
1099 | void OpieFtp::deleteServer() | 1087 | void OpieFtp::deleteServer() |
1100 | { | 1088 | { |
1101 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1089 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1102 | remoteServerStr = ServerComboBox->currentText( ); | 1090 | remoteServerStr = ServerComboBox->currentText( ); |
1103 | username = UsernameComboBox->currentText(); | 1091 | username = UsernameComboBox->currentText(); |
1104 | Config cfg("opieftp"); | 1092 | Config cfg("opieftp"); |
1105 | cfg.setGroup("Server"); | 1093 | cfg.setGroup("Server"); |
1106 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1094 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1107 | for (int i = 0; i <= numberOfEntries; i++) { | 1095 | for (int i = 0; i <= numberOfEntries; i++) { |
1108 | temp.setNum(i+1); | 1096 | temp.setNum(i+1); |
1109 | cfg.setGroup("Server"); | 1097 | cfg.setGroup("Server"); |
1110 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 | 1098 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 |
1111 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 | 1099 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 |
1112 | && !remoteServerStr.isEmpty()) { | 1100 | && !remoteServerStr.isEmpty()) { |
1113 | qDebug(temp); | 1101 | qDebug(temp); |
1114 | } | 1102 | } |
1115 | } | 1103 | } |
1116 | } | 1104 | } |