summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp153
1 files changed, 84 insertions, 69 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index fd6b028..907a812 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -56,154 +56,158 @@ static netbuf *conn=NULL;
56 56
57static int log_progress(netbuf *ctl, int xfered, void *arg) 57static int log_progress(netbuf *ctl, int xfered, void *arg)
58{ 58{
59 int fsz = *(int *)arg; 59 int fsz = *(int *)arg;
60 int pct = (xfered * 100) / fsz; 60 int pct = (xfered * 100) / fsz;
61// printf("%3d%%\r", pct); 61// printf("%3d%%\r", pct);
62// fflush(stdout); 62// fflush(stdout);
63 ProgressBar->setProgress(xfered); 63 ProgressBar->setProgress(xfered);
64 qApp->processEvents(); 64 qApp->processEvents();
65 return 1; 65 return 1;
66} 66}
67 67
68OpieFtp::OpieFtp( ) 68OpieFtp::OpieFtp( )
69 : QMainWindow( ) 69 : QMainWindow( )
70{ 70{
71 setCaption( tr( "OpieFtp" ) ); 71 setCaption( tr( "OpieFtp" ) );
72 72
73 QGridLayout *layout = new QGridLayout( this ); 73 QGridLayout *layout = new QGridLayout( this );
74 layout->setSpacing( 2); 74 layout->setSpacing( 2);
75 layout->setMargin( 2); 75 layout->setMargin( 2);
76 76
77 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 77 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
78 78
79 QPEMenuBar *menuBar = new QPEMenuBar(this); 79 QPEMenuBar *menuBar = new QPEMenuBar(this);
80 connectionMenu = new QPopupMenu( this ); 80 connectionMenu = new QPopupMenu( this );
81 localMenu = new QPopupMenu( this ); 81 localMenu = new QPopupMenu( this );
82 remoteMenu = new QPopupMenu( this ); 82 remoteMenu = new QPopupMenu( this );
83 tabMenu = new QPopupMenu( this ); 83 tabMenu = new QPopupMenu( this );
84 84
85 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); 85 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 );
86 86
87 menuBar->insertItem( tr( "Connection" ), connectionMenu); 87 menuBar->insertItem( tr( "Connection" ), connectionMenu);
88 menuBar->insertItem( tr( "Local" ), localMenu); 88 menuBar->insertItem( tr( "Local" ), localMenu);
89 menuBar->insertItem( tr( "Remote" ), remoteMenu); 89 menuBar->insertItem( tr( "Remote" ), remoteMenu);
90 menuBar->insertItem( tr( "View" ), tabMenu); 90 menuBar->insertItem( tr( "View" ), tabMenu);
91 91
92 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 92 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
93 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 93 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
94 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 94 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
95 95
96 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 96 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
97 localMenu->insertSeparator(); 97 localMenu->insertSeparator();
98 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 98 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
99 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 99 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
100 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 100 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
101 localMenu->insertSeparator(); 101 localMenu->insertSeparator();
102 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 102 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
103 localMenu->setCheckable(TRUE); 103 localMenu->setCheckable(TRUE);
104 104
105 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 105 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
106 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 106 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
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"),120); 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);
132 Local_View->setColumnAlignment(2,QListView::AlignRight); 132 Local_View->setColumnAlignment(2,QListView::AlignRight);
133 Local_View->setAllColumnsShowFocus(TRUE); 133 Local_View->setAllColumnsShowFocus(TRUE);
134 Local_View->setMultiSelection( TRUE );
135
134 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 136 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
135 137
136 tabLayout->addWidget( Local_View, 0, 0 ); 138 tabLayout->addWidget( Local_View, 0, 0 );
137 139
138 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 140 connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
139 this,SLOT( localListClicked(QListViewItem *)) ); 141 this,SLOT( localListClicked(QListViewItem *)) );
140 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 142 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
141 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 143 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
142 144
143 TabWidget->insertTab( tab, tr( "Local" ) ); 145 TabWidget->insertTab( tab, tr( "Local" ) );
144 146
145 tab_2 = new QWidget( TabWidget, "tab_2" ); 147 tab_2 = new QWidget( TabWidget, "tab_2" );
146 tabLayout_2 = new QGridLayout( tab_2 ); 148 tabLayout_2 = new QGridLayout( tab_2 );
147 tabLayout_2->setSpacing( 2); 149 tabLayout_2->setSpacing( 2);
148 tabLayout_2->setMargin( 2); 150 tabLayout_2->setMargin( 2);
149 151
150 Remote_View = new QListView( tab_2, "Remote_View" ); 152 Remote_View = new QListView( tab_2, "Remote_View" );
151 Remote_View->addColumn( tr("File"),120); 153 Remote_View->addColumn( tr("File"),150);
152 Remote_View->addColumn( tr("Size"),-1); 154 Remote_View->addColumn( tr("Size"),-1);
153 Remote_View->setColumnAlignment(1,QListView::AlignRight); 155 Remote_View->setColumnAlignment(1,QListView::AlignRight);
154 Remote_View->addColumn( tr("Date"),-1); 156 Remote_View->addColumn( tr("Date"),-1);
155 Remote_View->setColumnAlignment(2,QListView::AlignRight); 157 Remote_View->setColumnAlignment(2,QListView::AlignRight);
156 Remote_View->addColumn( tr("Dir"),-1); 158 Remote_View->addColumn( tr("Dir"),-1);
157 Remote_View->setColumnAlignment(4,QListView::AlignRight); 159 Remote_View->setColumnAlignment(4,QListView::AlignRight);
158 Remote_View->setAllColumnsShowFocus(TRUE); 160 Remote_View->setAllColumnsShowFocus(TRUE);
161 Remote_View->setMultiSelection( TRUE );
162
159 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 163 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
160 164
161 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 165 connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)),
162 this,SLOT( remoteListClicked(QListViewItem *)) ); 166 this,SLOT( remoteListClicked(QListViewItem *)) );
163 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 167 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
164 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 168 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
165 169
166 tabLayout_2->addWidget( Remote_View, 0, 0 ); 170 tabLayout_2->addWidget( Remote_View, 0, 0 );
167 171
168 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 172 TabWidget->insertTab( tab_2, tr( "Remote" ) );
169 173
170 tab_3 = new QWidget( TabWidget, "tab_3" ); 174 tab_3 = new QWidget( TabWidget, "tab_3" );
171 tabLayout_3 = new QGridLayout( tab_3 ); 175 tabLayout_3 = new QGridLayout( tab_3 );
172 tabLayout_3->setSpacing( 2); 176 tabLayout_3->setSpacing( 2);
173 tabLayout_3->setMargin( 2); 177 tabLayout_3->setMargin( 2);
174 178
175 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 179 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
176 TextLabel1->setText( tr( "Username" ) ); 180 TextLabel1->setText( tr( "Username" ) );
177 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 181 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
178 182
179 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 183 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
180 UsernameComboBox->setEditable(TRUE); 184 UsernameComboBox->setEditable(TRUE);
181 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 185 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
182 186
183 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 187 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
184 TextLabel2->setText( tr( "Password" ) ); 188 TextLabel2->setText( tr( "Password" ) );
185 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 189 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
186 190
187 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 191 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
188 PasswordEdit->setEchoMode(QLineEdit::Password); 192 PasswordEdit->setEchoMode(QLineEdit::Password);
189 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 193 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
190 194
191 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 195 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
192 TextLabel3->setText( tr( "Remote server" ) ); 196 TextLabel3->setText( tr( "Remote server" ) );
193 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 197 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
194 198
195 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 199 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
196 ServerComboBox->setEditable(TRUE); 200 ServerComboBox->setEditable(TRUE);
197 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 201 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
198 202
199 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); 203 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
200 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); 204 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) ));
201 205
202 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 206 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
203 TextLabel5->setText( tr( "Remote path" ) ); 207 TextLabel5->setText( tr( "Remote path" ) );
204 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 208 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
205 209
206 210
207 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 211 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
208 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 212 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
209 213
@@ -354,341 +358,353 @@ void OpieFtp::connector()
354 connectServerBtn->setOn(FALSE); 358 connectServerBtn->setOn(FALSE);
355 connectServerBtn->setText( tr("Connect")); 359 connectServerBtn->setText( tr("Connect"));
356 return; 360 return;
357 } 361 }
358 FtpInit(); 362 FtpInit();
359 TabWidget->setCurrentPage(1); 363 TabWidget->setCurrentPage(1);
360 QString ftp_host = ServerComboBox->currentText(); 364 QString ftp_host = ServerComboBox->currentText();
361 QString ftp_user = UsernameComboBox->currentText(); 365 QString ftp_user = UsernameComboBox->currentText();
362 QString ftp_pass = PasswordEdit->text(); 366 QString ftp_pass = PasswordEdit->text();
363 QString port=PortSpinBox->cleanText(); 367 QString port=PortSpinBox->cleanText();
364 port.stripWhiteSpace(); 368 port.stripWhiteSpace();
365 369
366 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 370 if(ftp_host.find("ftp://",0, TRUE) != -1 )
367 ftp_host=ftp_host.right(ftp_host.length()-6); 371 ftp_host=ftp_host.right(ftp_host.length()-6);
368 ftp_host+=":"+port; 372 ftp_host+=":"+port;
369 if (!FtpConnect( ftp_host.latin1(), &conn)) { 373 if (!FtpConnect( ftp_host.latin1(), &conn)) {
370 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 374 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
371 connectServerBtn->setOn(FALSE); 375 connectServerBtn->setOn(FALSE);
372 connectServerBtn->setText( tr("Connect")); 376 connectServerBtn->setText( tr("Connect"));
373 return ; 377 return ;
374 } 378 }
375 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 379 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
376 QString msg; 380 QString msg;
377 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 381 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
378 msg.replace(QRegExp(":"),"\n"); 382 msg.replace(QRegExp(":"),"\n");
379 QMessageBox::message(tr("Note"),msg); 383 QMessageBox::message(tr("Note"),msg);
380 if(conn) 384 if(conn)
381 FtpQuit(conn); 385 FtpQuit(conn);
382 connectServerBtn->setOn(FALSE); 386 connectServerBtn->setOn(FALSE);
383 connectServerBtn->setText( tr("Connect")); 387 connectServerBtn->setText( tr("Connect"));
384 return ; 388 return ;
385 } 389 }
386 remoteDirList("/") ; 390 remoteDirList("/") ;
387 setCaption(ftp_host); 391 setCaption(ftp_host);
388 writeConfig(); 392 writeConfig();
389 connectServerBtn->setText( tr("Disconnect")); 393 connectServerBtn->setText( tr("Disconnect"));
390 QCopEnvelope ( "QPE/System", "notBusy()" ); 394 QCopEnvelope ( "QPE/System", "notBusy()" );
391} 395}
392 396
393void OpieFtp::disConnector() 397void OpieFtp::disConnector()
394{ 398{
395 if(conn) 399 if(conn)
396 FtpQuit(conn); 400 FtpQuit(conn);
397 setCaption("OpieFtp"); 401 setCaption("OpieFtp");
398 currentRemoteDir="/"; 402 currentRemoteDir="/";
399 Remote_View->clear(); 403 Remote_View->clear();
400 connectServerBtn->setText( tr("Connect")); 404 connectServerBtn->setText( tr("Connect"));
401 connectServerBtn->setOn(FALSE); 405 connectServerBtn->setOn(FALSE);
402 406
403} 407}
404 408
405void OpieFtp::localUpload() 409void OpieFtp::localUpload()
406{ 410{
407 int fsz; 411 int fsz;
408 QCopEnvelope ( "QPE/System", "busy()" ); 412 QCopEnvelope ( "QPE/System", "busy()" );
409// qApp->processEvents(); 413// qApp->processEvents();
410 QString strItem = Local_View->currentItem()->text(0); 414 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
411 QString localFile = currentDir.canonicalPath()+"/"+strItem; 415 QListViewItemIterator it( Local_View );
412 QString remoteFile= currentRemoteDir+strItem; 416 for ( ; it.current(); ++it ) {
413 QFileInfo fi(localFile); 417 if ( it.current()->isSelected() ) {
414 if( !fi.isDir()) { 418 QString strItem = it.current()->text(0);
415 fsz=fi.size(); 419 QString localFile = currentDir.canonicalPath()+"/"+strItem;
416 ProgressBar->setTotalSteps(fsz); 420 QString remoteFile= currentRemoteDir+strItem;
417 421 QFileInfo fi(localFile);
418 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 422 if( !fi.isDir()) {
419 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 423 fsz=fi.size();
420 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 424 ProgressBar->setTotalSteps(fsz);
421 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 425
422 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 426 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
423 427 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
424 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 428 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
425 QString msg; 429 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
426 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 430 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
427 msg.replace(QRegExp(":"),"\n"); 431
428 QMessageBox::message(tr("Note"),msg); 432 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
433 QString msg;
434 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
435 msg.replace(QRegExp(":"),"\n");
436 QMessageBox::message(tr("Note"),msg);
437 }
438 } else {
439 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
440 }
441 ProgressBar->reset();
442 nullifyCallBack();
443 it.current()->setSelected(FALSE);
444 } //end currentSelected
429 } 445 }
430 ProgressBar->reset(); 446 TabWidget->setCurrentPage(1);
431 nullifyCallBack(); 447 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
432 } else { 448 QCopEnvelope ( "QPE/System", "notBusy()" );
433 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
434 }
435 TabWidget->setCurrentPage(1);
436 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
437 QCopEnvelope ( "QPE/System", "notBusy()" );
438} 449}
439 450
440void OpieFtp::nullifyCallBack() 451void OpieFtp::nullifyCallBack()
441{ 452{
442 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 453 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
443 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 454 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
444 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 455 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
445 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 456 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
446
447} 457}
448 458
449void OpieFtp::remoteDownload() 459void OpieFtp::remoteDownload()
450{ 460{
451// qApp->processEvents(); 461// qApp->processEvents();
452 int fsz; 462 int fsz;
453 QCopEnvelope ( "QPE/System", "busy()" ); 463 QCopEnvelope ( "QPE/System", "busy()" );
454 QString strItem = Remote_View->currentItem()->text(0);
455// strItem=strItem.right(strItem.length()-1);
456 464
457 QString localFile = currentDir.canonicalPath(); 465 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
458 if(localFile.right(1).find("/",0,TRUE) == -1) 466 QListViewItemIterator it( Remote_View );
459 localFile += "/"; 467 for ( ; it.current(); ++it ) {
460 localFile += strItem; 468 if ( it.current()->isSelected() ) {
469 QString strItem = it.current()->text(0);
470// strItem=strItem.right(strItem.length()-1);
471 QString localFile = currentDir.canonicalPath();
472 if(localFile.right(1).find("/",0,TRUE) == -1)
473 localFile += "/";
474 localFile += strItem;
461// QString localFile = currentDir.canonicalPath()+"/"+strItem; 475// QString localFile = currentDir.canonicalPath()+"/"+strItem;
462 QString remoteFile= currentRemoteDir+strItem; 476 QString remoteFile= currentRemoteDir+strItem;
463 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 477 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
464 fsz = 0; 478 fsz = 0;
465 QString temp; 479 QString temp;
466 temp.sprintf( remoteFile+" "+" %dkb", fsz); 480 temp.sprintf( remoteFile+" "+" %dkb", fsz);
467 481
468 ProgressBar->setTotalSteps(fsz); 482 ProgressBar->setTotalSteps(fsz);
469 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 483 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
470 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 484 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
471 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 485 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
472 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 486 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
473 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 487 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
474 488
475 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 489 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
476 QString msg; 490 QString msg;
477 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 491 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
478 msg.replace(QRegExp(":"),"\n"); 492 msg.replace(QRegExp(":"),"\n");
479 QMessageBox::message(tr("Note"),msg); 493 QMessageBox::message(tr("Note"),msg);
494 }
495 ProgressBar->reset();
496 nullifyCallBack();
497 it.current()->setSelected(FALSE);
498 }
480 } 499 }
481 ProgressBar->reset();
482 nullifyCallBack();
483 TabWidget->setCurrentPage(0); 500 TabWidget->setCurrentPage(0);
484 populateLocalView(); 501 populateLocalView();
485 QCopEnvelope ( "QPE/System", "notBusy()" ); 502 QCopEnvelope ( "QPE/System", "notBusy()" );
486} 503}
487 504
488bool OpieFtp::remoteDirList(const QString &dir) 505bool OpieFtp::remoteDirList(const QString &dir)
489{ 506{
490 QString tmp = QDir::homeDirPath(); 507 QString tmp = QDir::homeDirPath();
491 if(tmp.right(1) != "/") 508 if(tmp.right(1) != "/")
492 tmp+="/._temp"; 509 tmp+="/._temp";
493 else 510 else
494 tmp+="._temp"; 511 tmp+="._temp";
495// qDebug("Listing remote dir "+tmp); 512// qDebug("Listing remote dir "+tmp);
496 QCopEnvelope ( "QPE/System", "busy()" ); 513 QCopEnvelope ( "QPE/System", "busy()" );
497 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 514 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
498 QString msg; 515 QString msg;
499 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 516 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
500 msg.replace(QRegExp(":"),"\n"); 517 msg.replace(QRegExp(":"),"\n");
501 QMessageBox::message(tr("Note"),msg); 518 QMessageBox::message(tr("Note"),msg);
502 return false; 519 return false;
503 } 520 }
504 populateRemoteView() ; 521 populateRemoteView() ;
505 QCopEnvelope ( "QPE/System", "notBusy()" ); 522 QCopEnvelope ( "QPE/System", "notBusy()" );
506 return true; 523 return true;
507} 524}
508 525
509bool OpieFtp::remoteChDir(const QString &dir) 526bool OpieFtp::remoteChDir(const QString &dir)
510{ 527{
511 QCopEnvelope ( "QPE/System", "busy()" ); 528 QCopEnvelope ( "QPE/System", "busy()" );
512 if (!FtpChdir( dir.latin1(), conn )) { 529 if (!FtpChdir( dir.latin1(), conn )) {
513 QString msg; 530 QString msg;
514 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 531 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
515 msg.replace(QRegExp(":"),"\n"); 532 msg.replace(QRegExp(":"),"\n");
516 QMessageBox::message(tr("Note"),msg); 533 QMessageBox::message(tr("Note"),msg);
517 qDebug(msg); 534 qDebug(msg);
518 QCopEnvelope ( "QPE/System", "notBusy()" ); 535 QCopEnvelope ( "QPE/System", "notBusy()" );
519 return FALSE; 536 return FALSE;
520 } 537 }
521 QCopEnvelope ( "QPE/System", "notBusy()" ); 538 QCopEnvelope ( "QPE/System", "notBusy()" );
522 return TRUE; 539 return TRUE;
523} 540}
524 541
525void OpieFtp::populateLocalView() 542void OpieFtp::populateLocalView()
526{ 543{
527 Local_View->clear(); 544 Local_View->clear();
528 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 545 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
529 currentDir.setMatchAllDirs(TRUE); 546 currentDir.setMatchAllDirs(TRUE);
530 currentDir.setNameFilter(filterStr); 547 currentDir.setNameFilter(filterStr);
531 QString fileL, fileS, fileDate; 548 QString fileL, fileS, fileDate;
532 bool isDir=FALSE; 549 bool isDir=FALSE;
533 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 550 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
534 QFileInfoListIterator it(*list); 551 QFileInfoListIterator it(*list);
535 QFileInfo *fi; 552 QFileInfo *fi;
536 while ( (fi=it.current()) ) { 553 while ( (fi=it.current()) ) {
537 if (fi->isSymLink() ){ 554 if (fi->isSymLink() ){
538 QString symLink=fi->readLink(); 555 QString symLink=fi->readLink();
539// qDebug("Symlink detected "+symLink); 556// qDebug("Symlink detected "+symLink);
540 QFileInfo sym( symLink); 557 QFileInfo sym( symLink);
541 fileS.sprintf( "%10li", sym.size() ); 558 fileS.sprintf( "%10li", sym.size() );
542 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 559 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
543 fileDate = sym.lastModified().toString(); 560 fileDate = sym.lastModified().toString();
544 } else { 561 } else {
545// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 562// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
546 fileS.sprintf( "%10li", fi->size() ); 563 fileS.sprintf( "%10li", fi->size() );
547 fileL.sprintf( "%s",fi->fileName().data() ); 564 fileL.sprintf( "%s",fi->fileName().data() );
548 fileDate= fi->lastModified().toString(); 565 fileDate= fi->lastModified().toString();
549 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 566 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
550 fileL+="/"; 567 fileL+="/";
551 isDir=TRUE; 568 isDir=TRUE;
552// qDebug( fileL); 569// qDebug( fileL);
553 } 570 }
554 } 571 }
555 if(fileL !="./" && fi->exists()) { 572 if(fileL !="./" && fi->exists()) {
556 item= new QListViewItem( Local_View,fileL,fileS , fileDate); 573 item= new QListViewItem( Local_View,fileL,fileS , fileDate);
557 QPixmap pm; 574 QPixmap pm;
558 575
559 if(isDir || fileL.find("/",0,TRUE) != -1) { 576 if(isDir || fileL.find("/",0,TRUE) != -1) {
560 if( !QDir( fi->filePath() ).isReadable()) 577 if( !QDir( fi->filePath() ).isReadable())
561 pm = Resource::loadPixmap( "lockedfolder" ); 578 pm = Resource::loadPixmap( "lockedfolder" );
562 else 579 else
563 pm= Resource::loadPixmap( "folder" ); 580 pm= Resource::loadPixmap( "folder" );
564 item->setPixmap( 0,pm ); 581 item->setPixmap( 0,pm );
565 } else { 582 } else {
566 if( !fi->isReadable() ) 583 if( !fi->isReadable() )
567 pm = Resource::loadPixmap( "locked" ); 584 pm = Resource::loadPixmap( "locked" );
568 else { 585 else {
569 MimeType mt(fi->filePath()); 586 MimeType mt(fi->filePath());
570 pm=mt.pixmap(); 587 pm=mt.pixmap(); //sets the correct pixmap for mimetype
571 if(pm.isNull()) 588 if(pm.isNull())
572 pm = Resource::loadPixmap( "UnknownDocument-14" ); 589 pm = Resource::loadPixmap( "UnknownDocument-14" );
573 item->setPixmap( 0,pm); 590 item->setPixmap( 0,pm);
574 } 591 }
575 } 592 }
576 if( fileL.find("->",0,TRUE) != -1) { 593 if( fileL.find("->",0,TRUE) != -1) {
577 // overlay link image 594 // overlay link image
578 pm= Resource::loadPixmap( "folder" ); 595 pm= Resource::loadPixmap( "folder" );
579 QPixmap lnk = Resource::loadPixmap( "symlink" ); 596 QPixmap lnk = Resource::loadPixmap( "symlink" );
580 QPainter painter( &pm ); 597 QPainter painter( &pm );
581 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 598 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
582 pm.setMask( pm.createHeuristicMask( FALSE ) ); 599 pm.setMask( pm.createHeuristicMask( FALSE ) );
583 item->setPixmap( 0, pm); 600 item->setPixmap( 0, pm);
584 } 601 }
585 } 602 }
586 isDir=FALSE; 603 isDir=FALSE;
587 ++it; 604 ++it;
588 } 605 }
589 Local_View->setSorting( 3,FALSE); 606 Local_View->setSorting( 3,FALSE);
590 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 607 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
591 fillCombo( (const QString &)currentDir); 608 fillCombo( (const QString &)currentDir);
592
593} 609}
594 610
595bool OpieFtp::populateRemoteView( ) 611bool OpieFtp::populateRemoteView( )
596{ 612{
597// qDebug("populate remoteview"); 613// qDebug("populate remoteview");
598 QString sfile=QDir::homeDirPath(); 614 QString sfile=QDir::homeDirPath();
599 if(sfile.right(1) != "/") 615 if(sfile.right(1) != "/")
600 sfile+="/._temp"; 616 sfile+="/._temp";
601 else 617 else
602 sfile+="._temp"; 618 sfile+="._temp";
603 QFile file( sfile); 619 QFile file( sfile);
604 Remote_View->clear(); 620 Remote_View->clear();
605 QString s, File_Name; 621 QString s, File_Name;
606 QListViewItem *itemDir=NULL, *itemFile=NULL; 622 QListViewItem *itemDir=NULL, *itemFile=NULL;
607 QString fileL, fileS, fileDate; 623 QString fileL, fileS, fileDate;
608 if ( file.open(IO_ReadOnly)) { 624 if ( file.open(IO_ReadOnly)) {
609 QTextStream t( &file ); // use a text stream 625 QTextStream t( &file ); // use a text stream
610 while ( !t.eof()) { 626 while ( !t.eof()) {
611 s = t.readLine(); 627 s = t.readLine();
612 fileL = s.right(s.length()-55); 628 fileL = s.right(s.length()-55);
613 fileL = fileL.stripWhiteSpace(); 629 fileL = fileL.stripWhiteSpace();
614 if(s.left(1) == "d") 630 if(s.left(1) == "d")
615 fileL = fileL+"/"; 631 fileL = fileL+"/";
616// fileL = "/"+fileL+"/"; 632// fileL = "/"+fileL+"/";
617 fileS = s.mid( 30, 42-30); 633 fileS = s.mid( 30, 42-30);
618 fileS = fileS.stripWhiteSpace(); 634 fileS = fileS.stripWhiteSpace();
619 fileDate = s.mid( 42, 55-42); 635 fileDate = s.mid( 42, 55-42);
620 fileDate = fileDate.stripWhiteSpace(); 636 fileDate = fileDate.stripWhiteSpace();
621 if(fileL.find("total",0,TRUE) == -1) { 637 if(fileL.find("total",0,TRUE) == -1) {
622 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 638 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
623 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); 639 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d");
624 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 640 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
625// if(itemDir) 641// if(itemDir)
626 item->moveItem(itemDir); 642 item->moveItem(itemDir);
627 itemDir=item; 643 itemDir=item;
628 } else { 644 } else {
629 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); 645 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f");
630 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 646 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
631// if(itemFile) 647// if(itemFile)
632 item->moveItem(itemDir); 648 item->moveItem(itemDir);
633 item->moveItem(itemFile); 649 item->moveItem(itemFile);
634 itemFile=item; 650 itemFile=item;
635 } 651 }
636 } 652 }
637 } 653 }
638 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 654 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
639 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 655 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
640 file.close(); 656 file.close();
641 if( file.exists()) 657 if( file.exists())
642 file. remove(); 658 file. remove();
643 } else 659 } else
644 qDebug("temp file not opened successfullly "+sfile); 660 qDebug("temp file not opened successfullly "+sfile);
645 Remote_View->setSorting( 4,TRUE); 661 Remote_View->setSorting( 4,TRUE);
646 return true; 662 return true;
647} 663}
648 664
649void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 665void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
650{ 666{
651 if(item) { 667 if(item) {
652 QCopEnvelope ( "QPE/System", "busy()" ); 668 QCopEnvelope ( "QPE/System", "busy()" );
653 QString oldRemoteCurrentDir = currentRemoteDir; 669 QString oldRemoteCurrentDir = currentRemoteDir;
654 QString strItem=selectedItem->text(0); 670 QString strItem=selectedItem->text(0);
655 strItem=strItem.simplifyWhiteSpace(); 671 strItem=strItem.simplifyWhiteSpace();
656 if(strItem == "../") { // the user wants to go ^ 672 if(strItem == "../") { // the user wants to go ^
657 if( FtpCDUp( conn) == 0) { 673 if( FtpCDUp( conn) == 0) {
658 QString msg; 674 QString msg;
659 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 675 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
660 msg.replace(QRegExp(":"),"\n"); 676 msg.replace(QRegExp(":"),"\n");
661 QMessageBox::message(tr("Note"),msg); 677 QMessageBox::message(tr("Note"),msg);
662 qDebug(msg); 678 qDebug(msg);
663 } 679 }
664 char path[256]; 680 char path[256];
665 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 681 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
666 QString msg; 682 QString msg;
667 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 683 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
668 msg.replace(QRegExp(":"),"\n"); 684 msg.replace(QRegExp(":"),"\n");
669 QMessageBox::message(tr("Note"),msg); 685 QMessageBox::message(tr("Note"),msg);
670 qDebug(msg); 686 qDebug(msg);
671 } 687 }
672 currentRemoteDir=path; 688 currentRemoteDir=path;
673 } else { 689 } else {
674 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 690 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
675 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 691 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
676 strItem = strItem.stripWhiteSpace(); 692 strItem = strItem.stripWhiteSpace();
677 currentRemoteDir = strItem; 693 currentRemoteDir = strItem;
678 if( !remoteChDir( (const QString &)strItem)) { 694 if( !remoteChDir( (const QString &)strItem)) {
679 currentRemoteDir = oldRemoteCurrentDir; 695 currentRemoteDir = oldRemoteCurrentDir;
680 strItem=""; 696 strItem="";
681 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 697 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
682 } 698 }
683 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 699 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
684 qDebug("trying directory"); 700 qDebug("trying directory");
685 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 701 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
686 currentRemoteDir = oldRemoteCurrentDir; 702 currentRemoteDir = oldRemoteCurrentDir;
687 strItem=""; 703 strItem="";
688 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 704 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
689 705
690 } else { 706 } else {
691 currentRemoteDir = currentRemoteDir+strItem; 707 currentRemoteDir = currentRemoteDir+strItem;
692 } 708 }
693 } else { 709 } else {
694 qDebug("download "+strItem); 710 qDebug("download "+strItem);
@@ -714,249 +730,248 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem)
714 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 730 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
715 if(QDir(strItem2).exists() ) { 731 if(QDir(strItem2).exists() ) {
716 currentDir.cd(strItem2, TRUE); 732 currentDir.cd(strItem2, TRUE);
717 populateLocalView(); 733 populateLocalView();
718 } 734 }
719 } else { // not a symlink 735 } else { // not a symlink
720 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 736 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
721 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 737 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
722 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 738 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
723 currentDir.cd(strItem,FALSE); 739 currentDir.cd(strItem,FALSE);
724 populateLocalView(); 740 populateLocalView();
725 } else { 741 } else {
726 currentDir.cdUp(); 742 currentDir.cdUp();
727 populateLocalView(); 743 populateLocalView();
728 } 744 }
729 if(QDir(strItem).exists()){ 745 if(QDir(strItem).exists()){
730 currentDir.cd(strItem, TRUE); 746 currentDir.cd(strItem, TRUE);
731 populateLocalView(); 747 populateLocalView();
732 } 748 }
733 } else { 749 } else {
734 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 750 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
735 if( QFile::exists(strItem ) ) { 751 if( QFile::exists(strItem ) ) {
736 qDebug("upload "+strItem); 752 qDebug("upload "+strItem);
737 } 753 }
738 } //end not symlink 754 } //end not symlink
739 chdir(strItem.latin1()); 755 chdir(strItem.latin1());
740 } 756 }
741 } 757 }
742} 758}
743 759
744void OpieFtp::doLocalCd() 760void OpieFtp::doLocalCd()
745{ 761{
746 localListClicked( Local_View->currentItem()); 762 localListClicked( Local_View->currentItem());
747} 763}
748 764
749void OpieFtp:: doRemoteCd() 765void OpieFtp:: doRemoteCd()
750{ 766{
751 remoteListClicked( Remote_View->currentItem()); 767 remoteListClicked( Remote_View->currentItem());
752 768
753} 769}
754 770
755void OpieFtp::showHidden() 771void OpieFtp::showHidden()
756{ 772{
757 if (!b) { 773 if (!b) {
758 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 774 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
759 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 775 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
760// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 776// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
761 b=TRUE; 777 b=TRUE;
762 778
763 } else { 779 } else {
764 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 780 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
765 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 781 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
766// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 782// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
767 b=FALSE; 783 b=FALSE;
768 } 784 }
769 populateLocalView(); 785 populateLocalView();
770} 786}
771 787
772void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 788void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
773{ 789{
774 switch (mouse) { 790 switch (mouse) {
775 case 1: 791 case 1:
776 break; 792 break;
777 case 2: 793 case 2:
778 showLocalMenu(item); 794 showLocalMenu(item);
779 break; 795 break;
780 }; 796 };
781} 797}
782 798
783void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 799void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
784{ 800{
785 switch (mouse) { 801 switch (mouse) {
786 case 1: 802 case 1:
787 break; 803 break;
788 case 2: 804 case 2:
789 showRemoteMenu(item); 805 showRemoteMenu(item);
790 break; 806 break;
791 }; 807 };
792} 808}
793 809
794void OpieFtp::showRemoteMenu(QListViewItem * item) 810void OpieFtp::showRemoteMenu(QListViewItem * item)
795{ 811{
796 QPopupMenu m;// = new QPopupMenu( Local_View ); 812 QPopupMenu m;// = new QPopupMenu( Local_View );
797 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 813 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
798 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 814 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
799 else 815 else
800 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 816 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
801 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 817 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
802 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 818 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
803 m.insertSeparator(); 819 m.insertSeparator();
804 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 820 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
805 m.exec( QCursor::pos() ); 821 m.exec( QCursor::pos() );
806} 822}
807 823
808void OpieFtp::showLocalMenu(QListViewItem * item) 824void OpieFtp::showLocalMenu(QListViewItem * item)
809{ 825{
810 QPopupMenu m; 826 QPopupMenu m;
811 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 827 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
812 m.insertSeparator(); 828 m.insertSeparator();
813 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 829 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
814 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 830 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
815 else 831 else
816 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 832 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
817 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 833 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
818 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 834 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
819 m.insertSeparator(); 835 m.insertSeparator();
820 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 836 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
821 m.setCheckable(TRUE); 837 m.setCheckable(TRUE);
822 if (b) 838 if (b)
823 m.setItemChecked(m.idAt(0),TRUE); 839 m.setItemChecked(m.idAt(0),TRUE);
824 else 840 else
825 m.setItemChecked(m.idAt(0),FALSE); 841 m.setItemChecked(m.idAt(0),FALSE);
826 842
827 m.exec( QCursor::pos() ); 843 m.exec( QCursor::pos() );
828} 844}
829 845
830void OpieFtp::localMakDir() 846void OpieFtp::localMakDir()
831{ 847{
832 InputDialog *fileDlg; 848 InputDialog *fileDlg;
833 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 849 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
834 fileDlg->exec(); 850 fileDlg->exec();
835 if( fileDlg->result() == 1 ) { 851 if( fileDlg->result() == 1 ) {
836 QString filename = fileDlg->LineEdit1->text(); 852 QString filename = fileDlg->LineEdit1->text();
837 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 853 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
838 } 854 }
839 populateLocalView(); 855 populateLocalView();
840} 856}
841 857
842void OpieFtp::localDelete() 858void OpieFtp::localDelete()
843{ 859{
844 QString f = Local_View->currentItem()->text(0); 860 QString f = Local_View->currentItem()->text(0);
845 if(QDir(f).exists() ) { 861 if(QDir(f).exists() ) {
846 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 862 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
847 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 863 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
848 case 0: { 864 case 0: {
849 f=currentDir.canonicalPath()+"/"+f; 865 f=currentDir.canonicalPath()+"/"+f;
850 QString cmd="rmdir "+f; 866 QString cmd="rmdir "+f;
851 system( cmd.latin1()); 867 system( cmd.latin1());
852 populateLocalView(); 868 populateLocalView();
853 } 869 }
854 break; 870 break;
855 case 1: 871 case 1:
856 // exit 872 // exit
857 break; 873 break;
858 }; 874 };
859 875
860 } else { 876 } else {
861 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 877 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
862 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 878 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
863 case 0: { 879 case 0: {
864 f=currentDir.canonicalPath()+"/"+f; 880 f=currentDir.canonicalPath()+"/"+f;
865 QString cmd="rm "+f; 881 QString cmd="rm "+f;
866 system( cmd.latin1()); 882 system( cmd.latin1());
867 populateLocalView(); 883 populateLocalView();
868 } 884 }
869 break; 885 break;
870 case 1: 886 case 1:
871 // exit 887 // exit
872 break; 888 break;
873 }; 889 };
874 } 890 }
875} 891}
876 892
877void OpieFtp::remoteMakDir() 893void OpieFtp::remoteMakDir()
878{ 894{
879 InputDialog *fileDlg; 895 InputDialog *fileDlg;
880 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 896 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
881 fileDlg->exec(); 897 fileDlg->exec();
882 if( fileDlg->result() == 1 ) { 898 if( fileDlg->result() == 1 ) {
883 QString filename = fileDlg->LineEdit1->text();//+".playlist"; 899 QString filename = fileDlg->LineEdit1->text();//+".playlist";
884 QString tmp=currentRemoteDir+filename; 900 QString tmp=currentRemoteDir+filename;
885 QCopEnvelope ( "QPE/System", "busy()" ); 901 QCopEnvelope ( "QPE/System", "busy()" );
886 if(FtpMkdir( tmp.latin1(), conn) == 0) { 902 if(FtpMkdir( tmp.latin1(), conn) == 0) {
887 QString msg; 903 QString msg;
888 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); 904 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn));
889 msg.replace(QRegExp(":"),"\n"); 905 msg.replace(QRegExp(":"),"\n");
890 QMessageBox::message(tr("Note"),msg); 906 QMessageBox::message(tr("Note"),msg);
891 } 907 }
892 QCopEnvelope ( "QPE/System", "notBusy()" ); 908 QCopEnvelope ( "QPE/System", "notBusy()" );
893 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 909 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
894 } 910 }
895} 911}
896 912
897void OpieFtp::remoteDelete() 913void OpieFtp::remoteDelete()
898{ 914{
899 QString f = Remote_View->currentItem()->text(0); 915 QString f = Remote_View->currentItem()->text(0);
900 QCopEnvelope ( "QPE/System", "busy()" ); 916 QCopEnvelope ( "QPE/System", "busy()" );
901 if( f.right(1) =="/") { 917 if( f.right(1) =="/") {
902 QString path= currentRemoteDir+f; 918 QString path= currentRemoteDir+f;
903 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 919 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
904 ,tr("Yes"),tr("No"),0,0,1) ) { 920 ,tr("Yes"),tr("No"),0,0,1) ) {
905 case 0: { 921 case 0: {
906 f=currentDir.canonicalPath()+"/"+f; 922 f=currentDir.canonicalPath()+"/"+f;
907 if(FtpRmdir( path.latin1(), conn) ==0) { 923 if(FtpRmdir( path.latin1(), conn) ==0) {
908 QString msg; 924 QString msg;
909 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); 925 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
910 msg.replace(QRegExp(":"),"\n"); 926 msg.replace(QRegExp(":"),"\n");
911 QMessageBox::message(tr("Note"),msg); 927 QMessageBox::message(tr("Note"),msg);
912 } 928 }
913 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 929 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
914
915 } 930 }
916 break; 931 break;
917 }; 932 };
918 } else { 933 } else {
919 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 934 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
920 ,tr("Yes"),tr("No"),0,0,1) ) { 935 ,tr("Yes"),tr("No"),0,0,1) ) {
921 case 0: { 936 case 0: {
922 QString path= currentRemoteDir+f; 937 QString path= currentRemoteDir+f;
923 if(FtpDelete( path.latin1(), conn)==0) { 938 if(FtpDelete( path.latin1(), conn)==0) {
924 QString msg; 939 QString msg;
925 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 940 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
926 msg.replace(QRegExp(":"),"\n"); 941 msg.replace(QRegExp(":"),"\n");
927 QMessageBox::message(tr("Note"),msg); 942 QMessageBox::message(tr("Note"),msg);
928 } 943 }
929 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 944 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
930 } 945 }
931 break; 946 break;
932 }; 947 };
933 } 948 }
934 QCopEnvelope ( "QPE/System", "notBusy()" ); 949 QCopEnvelope ( "QPE/System", "notBusy()" );
935} 950}
936 951
937void OpieFtp::remoteRename() 952void OpieFtp::remoteRename()
938{ 953{
939 QString curFile = Remote_View->currentItem()->text(0); 954 QString curFile = Remote_View->currentItem()->text(0);
940 InputDialog *fileDlg; 955 InputDialog *fileDlg;
941 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 956 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
942 fileDlg->inputText = curFile; 957 fileDlg->inputText = curFile;
943 fileDlg->exec(); 958 fileDlg->exec();
944 if( fileDlg->result() == 1 ) { 959 if( fileDlg->result() == 1 ) {
945 QString oldName = currentRemoteDir +"/"+ curFile; 960 QString oldName = currentRemoteDir +"/"+ curFile;
946 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 961 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
947 QCopEnvelope ( "QPE/System", "busy()" ); 962 QCopEnvelope ( "QPE/System", "busy()" );
948 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 963 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
949 QString msg; 964 QString msg;
950 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); 965 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
951 msg.replace(QRegExp(":"),"\n"); 966 msg.replace(QRegExp(":"),"\n");
952 QMessageBox::message(tr("Note"),msg); 967 QMessageBox::message(tr("Note"),msg);
953 } 968 }
954 QCopEnvelope ( "QPE/System", "notBusy()" ); 969 QCopEnvelope ( "QPE/System", "notBusy()" );
955 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 970 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
956 } 971 }
957} 972}
958 973
959void OpieFtp::localRename() 974void OpieFtp::localRename()
960{ 975{
961 QString curFile = Local_View->currentItem()->text(0); 976 QString curFile = Local_View->currentItem()->text(0);
962 InputDialog *fileDlg; 977 InputDialog *fileDlg;